Forum Moderators: phranque

Message Too Old, No Replies

Mod_Rewrite

My Code won't work

         

chriswragg

3:59 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



I have moved my site to a subdomain called web. I want any attempts to request a folder, say example.com/news, to be redirected to web.example.com/news.

I have tried the code below, but with no success. Can you help correct this for me?

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^http://example.com/(.*)(/)? [web.example.com...] [R]

Thanks for any help

Chris

ChadSEO

5:25 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)/?$ [web.example.com...] [R=301]

Hmmm, I think this should work for you, assuming I didn't make any typos. I'm sure jdMorgan will come in and make a change or two, he's always cleaning up after my mistakes :)

chriswragg

5:47 pm on Jul 29, 2005 (gmt 0)

10+ Year Member



That's fine how it is :)
Thanks for the help

Chris

jdMorgan

6:26 pm on Jul 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would suggest:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://web.example.com/$1 [R=301,L]

so that trailing slashes are not added to non-directory requests. (The start and end anchors on a ".*" pattern standing alone are unnecessary.)

Jim