Forum Moderators: phranque

Message Too Old, No Replies

htaccess rewrite rule for .com domain

         

jamiecottonuk

1:46 pm on Jun 10, 2010 (gmt 0)

10+ Year Member



Could someone please point me in the right direction.

I want to create a rewrite rule so that if a user accesses the site on www.foo.com it would request www.foo.com/foo/index.php

So basically if they come through www.foo.com all of the php pages would be forced to go through the foo php controller. However if they accessed www.foo.co.uk they wouldn't.

With the rewrite rule
www.foo.com/testpage would go to www.foo.com/foo/testpage
www.foo.com/about-us would go to www.foo.com/foo/about-us
www.foo.com/contact-us would go to www.foo.com/foo/contact-us


www.foo.co.uk/testpage would go to www.foo.co.uk/testpage
www.foo.co.uk/about-us would go to www.foo.co.uk/about-us
www.foo.co.uk/contact-us would go to www.foo.co.uk/contact-us

Of course there are more than 3 pages but the above was just to give an example. Also the url in the address bar must stay www.foo.com/testpage, www.foo.com/about-us etc not not display the middle controller

Cheers

jdMorgan

4:37 pm on Jun 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So for those examples, you need:

A RewriteCond to examine %{HTTP_HOST} and match "www.foo.com"
A RewriteRule to rewrite the URL-path "/<letters or hyphens>" to /foo/index.php

Please review our Apache Forum Charter, then (using the resources cited therein if needed) post your best-effort at coding a solution as a basis for discussion.

Thanks,
Jim