Forum Moderators: coopster

Message Too Old, No Replies

Address bar show old URL when redirect to new url? Is that possible?

Thanks for helping me this question.

         

fufu

5:24 am on Jun 18, 2005 (gmt 0)

10+ Year Member



I am a newbie about Apache, so please donot laugh if this question is too simple.

My question is:
when user request a url like:
wwWebmasterWorldeb.com/keyword
I redirect his request to my real html file
wwWebmasterWorldeb.com/keyword/keyword1.htm,

But I wish the address bar is still showing his url request. in another world, keep short url,
so easy to remember.

anyway, any guru know an answer to this?
thanks so much!

[edited by: jatar_k at 2:54 pm (utc) on June 18, 2005]
[edit reason] no urls thanks [/edit]

RonPK

9:45 am on Jun 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Soudns like you're entering the magic world of mod_rewrite! The real guru's hang out in the Apache forum [webmasterworld.com], where you'll find many similar questions.

hakre

9:48 am on Jun 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmm, are you using apache or php for the redirect?

in general the phenomena you describe is possible (especially with IE) and if you don't like that, then use a permanent redirect (301) by adding an additional header

php:
> header("Status: 301 Moved Permanently",true,301);

apache:
> Redirect 301 /keyword h**p://example.com/keyword/keyword1.htm
or
> Redirect permanent /keyword h**p://example.com/keyword/keyword1.htm

this should do the trick. by using the status header in php you avoid specifieing the http version (1.0 or 1.1). but keep in mind that this status code (301) tells the client that wwWebmasterWorldeb.com/keyword has moved to
wwWebmasterWorldeb.com/keyword/keyword1.htm permanently. i.e. robots will index the .htm in the future, not /keyword, bookmark collections might automaticaly update their bookmarks etc. .

edit: (for completition)
with mod_rewrite (as mentioned by RonPK), you can use the R or redirect flag with its additional parameter (=code) on the RewriteRule:

> RewriteRule ^/keyword$ h**p:/example.com/keyword/keyword1.htm [R=301]