Forum Moderators: phranque
Now I need to set up a redirect from an old file that I'm going to delete and point it to another one (I want the search engines to record this as permanent). Here is the code I'm using,
RewriteRule ^old\.shtml$ new.shtml [R=301,L]
however it isn't working. It works on other sites that aren't located in httpdocs so I suspect that is the problem.
I get this error:
The requested URL /var/www/vhosts/EXAMPLE.com/httpdocs/NEW.shtml was not found on this server.
both of these files are in the root of httpdocs.
Can someone tell what the problem is?
[edited by: Lorel at 6:43 pm (utc) on Feb. 28, 2007]
Basically, we need a lot more detail:
What is the (full) URL to be rewritten?
What is the (full) new URL?
What is the server filepath for the file that is to be rewritten?
What is the server filepath to the new file?
Where is the .htaccess file (what filepath)?
What URL did you request to test this?
What URL and filepath did you expect it to be rewritten to?
How does the filepath you got in the error log differ from the filepath you expected?
What are the differences between your rule that works and this one that doesn't?
You highlighted "EXAMPLE.com" in the error message. Is that significant?
There's some redundancy in this list, but that's better than leaving things out. It appears that the redirect *was* invoked, but that the filepath that the new URL resolves to is wrong. But I can't be sure of any of this.
This stuff is just hard to talk about and to describe accurately. Therefore, the more detail in your posts, the better.
The only thing I see that is even marginally "wrong" is the format of your rule. It may not work on a server that has UseCanonicalName set to "On". A more robust format is:
RewriteRule ^old\.shtml$ http://www.example.com/new.shtml [R=301,L]
Jim