Forum Moderators: phranque

Message Too Old, No Replies

Mod-Rewrite Question

rewrite website.com to website.com/home

         

jncr

11:15 pm on Mar 2, 2008 (gmt 0)

10+ Year Member



Hi, I am relatively new to Apache and Mod-Rewrite. I need to know how to rewrite website.com to website.com/home.

I also need it to rewrite anything.website.com to website.com.

For example I am wanting a script that if a user just types website.com, it will show them the contents of website.com/home. However, if they enter a subdomain (virtual) it will show them the contents of website.com

I have been experimenting with this, and have gotten the first thing to work, but when I tried the second thing, it gave me an infinite loop.

Thank you for any future feedback.

~JNCR

jdMorgan

11:57 pm on Mar 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post your code as a basis for discussion.

Thanks,
Jim

jncr

12:07 am on Mar 3, 2008 (gmt 0)

10+ Year Member




Options FollowSymLinks Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.website\.com [NC]
RewriteRule (.*) http://website.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^website\.com
RewriteCond $1 !^home/
RewriteRule (.*) http://website.com/home/$1 [L]

I thought this would work, but it doesn't.

g1smd

12:14 am on Mar 3, 2008 (gmt 0)

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



This question was asked yesterday in another thread, with some small differences.

This thread gives some starting clues [webmasterworld.com...] but will need several modifications.

jncr

12:29 am on Mar 3, 2008 (gmt 0)

10+ Year Member



Ok thanks I fixed it

g1smd

1:04 am on Mar 3, 2008 (gmt 0)

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



Please post code as to "how" you fixed it, for the benefit of the next person who needs the answer...