Forum Moderators: coopster & phranque

Message Too Old, No Replies

.htaccess Redirect vs RedirectMatch

         

tilt

1:53 am on Jan 16, 2002 (gmt 0)

10+ Year Member



I changed the name of one of my html files. Then I altered the content of the new file. The old file has been indexed by google so I wanted to do a redirect. I tried:
Redirect permanent /old.html /new.html
but got a server error. Then I tried:
RedirectMatch permanent /old.html /new.html
and that works.

Is that the right way to redirect one specific file to another or am I missing something? Frankly, I didn't understand the Apache docs at all. What's a %-encoded and %-decoded url? I guess a url-path is not the same as a file name but needs to be a directory?

Thanks!

bobriggs

2:23 am on Jan 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try:

redirect permanent /old.html [mydomain.com...]

Key_Master

2:32 am on Jan 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This would work also.

Redirect 301 /old.html [your_domain.com...]

In case you speak HEX, I encoded the above message for you. :)

%54%68%69%73%20%77%6f%75%6c%64%20%77%6f%72%6b%20%61%6c%73%6f
%2e%d%a%d%a%52%65%64%69%72%65%63%74%20%33%30%31%20%2f%6f%6c
%64%2e%68%74%6d%6c%20%68%74%74%70%3a%2f%2f%79%6f%75%72%5f%64
%6f%6d%61%69%6e%2e%63%6f%6d%2f%6e%65%77%2e%68%74%6d%6c

(edited by: Key_Master at 4:06 am (utc) on Jan. 16, 2002)

tilt

3:49 am on Jan 16, 2002 (gmt 0)

10+ Year Member



Thanks guys. That works. I guess the 2nd argument needs to be a fully qualified url.

Here's how the apache docs describe it:

Redirect [status] URL-path URL
URL-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) URL beginning with URL

Now if that isn't as clear as Turkish coffee...

Key_master, did your Hex hex put a spell on this topic and make the line length abominable? :)

Key_Master

4:03 am on Jan 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I was using IE6. The HEX is wrapping just fine here. Loaded the same page with Mozilla and the code is not wrapping. I'll edit the post...