Forum Moderators: phranque
Towards the bottom of the main code at
[webmasterworld.com...]
there is this section
# Redirect all pages in old directories to same-named pages in new directories
RewriteCond /new_dir1<>%{ENV:myURI} ^([^<]+)<>/old_dir1(.+)$ [NC,OR]
RewriteCond /new_dir2<>%{ENV:myURI} ^([^<]+)<>/old_dir2(.+)$ [NC]
RewriteRule . - [E=qRed:yes,E=myURI:%1%2]
At the moment I have this and it doesnt work
RewriteCond /NEWFOLDERNAME<>%{ENV:myURI} ^([^<]+)<>/OLDFOLDERNAME(.+)$ [NC,OR]
RewriteCond /NEWFOLDERNAME<>%{ENV:myURI} ^([^<]+)<>/OLDFOLDERNAME(.+)$ [NC]
RewriteRule . - [E=qRed:yes,E=myURI:%1%2]
I am having problems understanding how to adapt all of this code for my site.
I have chaged all the broken pipes to proper pipes as explained.
I have changed example.com to mysite.com
I presume new_dirX and old_dirX should be replaced by the new and old directories.
Im not sure if myURI is something I need to replace?
Im not sure if there is anything else here I need to replace.
This looks like such a useful code.
Please could someone write a more detailed explanation for total beginners as to how to modify it for their own site?
Something that points out every place where you have to change the code to your own specific URLs etc.
Thanks
Dan V
Rather than starting with that code, I'd suggest using the far simpler examples posted elsewhere in this forum and in our forum library [webmasterworld.com]. (If it's any indication, I only use parts of that code when I absolutely have to, and I wrote it!)
No matter what code you decide to base your work on, remember that it controls some aspect --large or small-- of your server configuration. So do not deploy any code that you do not fully understand --or even code that you do fully understand-- if you don't know all of the implications of its use. One typo or one extra or missing [NC] flag could cost you the search engine ranking of your site -- and possibly for a very long time if you don't catch the error right away.
In mod_rewrite, you're looking at a chain saw -- very useful and quite powerful, but potentially very dangerous...
Also, take a look at the Apache mod_rewrite documentation [httpd.apache.org], and at the Apache URL Rewriting Guide linked from there as well.
Jim