Forum Moderators: phranque
I know this topic has been covered before, so please forgive me for reposting - I've been doing lots of searching on webmasterworld for a solution to my rewrite-problem, but I haven't found the holy grail yet! I knitted some code together to externally redirect dynamic to static:
'RewriteRule widget/number(.*)/ widget.php?number=$1'
jdMorgan's article www.webmasterworld.com/forum92/6079.htm also shows how redirects should be directed internally - but alas, my poor coding-skills forbid me from making a decent internal redirect. I want requests for the following dynamic url to automatically redirect to the static url below:
www.mywebsite.com/widget.php?number=$1
www.mywebsite.com/widget/number123/
Thanks for your help!
Best
Tanx
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?product=([^&]+)&color=([^&]+)&size=([^&]+)&texture=([^&]+)&maker=([^\ ]+)\ HTTP/
RewriteRule ^index\.php$ http://example.com/product/%1/%2/%3/%4/%5? [R=301,L]
I've tried and tried, but to no avail I'm afraid - can you help? - I'm sorry for bugging you! :S
Btw. this refers to your bit about external (not internal, as I erroneously wrote) redirection
All the best,
Tanx
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /widget\.php\?number=([^&]+)\ HTTP/
RewriteRule ^widget\.php$ http://example.com/widget/number%1/? [R=301,L]
This is the third of three steps for using search-engine-friendly URLs, as described in the thread you cited. Be sure you've got the other two pieces in place first; Internally rewrite the friendly URLs to your script, and then change the links on your pages to use the friendly URLs. Only then is this third step useful (and safe).
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
An Internal Rewrite is where the link says, and the user requests, /aaaa.html and the server silently fetches the content from the file bbbb.html and sends it with a "200 OK" response. The user does not "see" the bbbb.html URL at all.
An External Redirect is where the link says, and the user requests, /bbbb.html and then the server responds with a "301 Moved" response and the URL of where the information actually resides. The browser then makes a new request, this time for aaaa.html and that information is then returned with a "200 OK" response code.