Forum Moderators: phranque

Message Too Old, No Replies

Can't redirect file on httpdocs

301 isn't working

         

Lorel

6:42 pm on Feb 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have an htacces file set up already fixing the cannonical problem and it's working fine and I also set up a page as gone [G] and its working.

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]

Lorel

4:45 pm on Mar 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Anyone know what is wrong with the above code?

jdMorgan

5:11 pm on Mar 1, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, the problem is not clear. I don't know the actual URL-path of the URL you want to rewrite. I do not know what the expected filepath is, so I can't tell if it's right or wrong. I don't know if httpdocs is Web-accessible (if it isn't, you cannot redirect using code there). I don't know anything about your server, for practical purposes. Therefore, it's hard to speculate.

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

Lorel

3:04 am on Mar 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi JD

Thanks for your input. It works now. I think i just needed full urls.