Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
htaccess - is it me or the hosted server vero msg:4391786 8:49 pm on Nov 28, 2011 (gmt 0) Here's the htaccess file: redirect 301 /directory/old1.htm http://www.example.org/new1.htm redirect 301 /directory/old2.htm http://www.example.org/new2.htm But when it redirects, it adds the old file name like this: http://www.example.org/new1.htmold1.htm http://www.example.org/new2.htmold2.htm which of course is not found Am I doing something wrong here, or is there an issue with my hosted server? Thanks!
g1smd msg:4391795 9:09 pm on Nov 28, 2011 (gmt 0)
Use RewriteRule and the [R=301,L] flag, not Redirect here. It gives you more control. vero msg:4391806 9:26 pm on Nov 28, 2011 (gmt 0)
Thanks so much for the fast reply. The old files were in a directory no longer being used. The new ones are in the root directory and have different names. Is this correct then? RewriteEngine On RewriteRule ^/directory/old1\.htm$ new1.htm [L,R=301] RewriteRule ^/directory/old2\.htm$ new2.htm [L,R=301] lucy24 msg:4391847 11:32 pm on Nov 28, 2011 (gmt 0)
No. In mod_rewrite unlike mod_alias you leave off the leading slash from the pattern but include it in the target. And-- this part is the same for both mods-- include the full protocol and domain name unless you're on a hosting plan that has already regularized the whole thing before it ever gets to your htaccess. (If so, it won't do any harm but isn't as essential.) But your original Redirect version still should not have reappended the filename. mod_alias is only supposed to reappend the rest of the path, if any. vero msg:4391858 1:09 am on Nov 29, 2011 (gmt 0)
Thank you so much. I didn't think the original way I had it would cause it to append the filename either. But in any event, rewrite is working: RewriteRule ^directory/old1\.htm$ http://www.example.org/new1.htm [L,R=301] Thanks again