Forum Moderators: phranque

Message Too Old, No Replies

simple mod rewrite help

         

catchmeifucan

4:56 am on May 7, 2005 (gmt 0)

10+ Year Member



I have a subdomain store.mystore.com, how do I 301 redirect all pages under it to my www.mystore.com?

for example,

store.mystore.com/xyz.html -> www.mystore.com/xyz.html

I have a lot of xyz pages, what is the mod rewrite rule I should use?

jd01

5:09 am on May 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi catchmeifucan,

You're right this one is fairly easy...

RewriteEngine ON
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301,L]

So you have an idea of what it does here goes:
^ starts the line
(.*) catches any string and stores it in a variable.
$ ends the line

The canonical URL causes an external redirect.
R=301 redefines the redirect from the default (302/temproary) to a 301/permanent.
L says stop processing now.

Hope this helps.

Justin

catchmeifucan

4:03 pm on May 8, 2005 (gmt 0)

10+ Year Member



Justin,

I played with it but didn't work out. can you just give me a simple line of code that should work?

Thanks

jd01

5:03 pm on May 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi catchmeifucan,

That one should work...

What do you mean by not working out?
Which site did you put it on?
What directory did you put it in?
What exactly do you want it to do?

Please, let me know.

Justin

catchmeifucan

3:56 pm on May 9, 2005 (gmt 0)

10+ Year Member



Hi, Justin,

Thanks a lot. It did work.