from phpquery to subdomain

Discuss practical ways rearrange URLs using mod_rewrite.

from phpquery to subdomain

Postby Dominik101 » Sun Mar 01, 2009 11:44 pm

Hi,

I have this problem.

I would like a mod rewrite code that will do the following thing:

www.example.com/booking/phpquery -> rewrite to -> booking.example.com/phpquery

I don't want to send a redirect to the browser (so it doesn't know the page is different).

Another example, just to clarify.

If
http://www.example.com/booking/phpquery is entered into the browser, Apache returns the content of
http://booking.example.com/phpquery

I should mentioned here that bookings is a CNAME which points to another domain which i'm affiliated with. So i'm pulling the content from provider website, which is prepared for me, with my logo etc.

I could stay with the solution bookings.example.com/phpquerry, but I will have also other CNAMEs, so solution www.example.com/<various CNAMEs>/ is better for SEO and customers

I tried the code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^bookings/(.*) http://bookings.thecheaphotelreservations.com/$1

which is doing the job right, but the address bar changes to:
http://booking.example.com/phpquery, (instead of staying the same http://www.example.com/booking/phpquery)

How should I do it?
Dominik101
 
Posts: 3
Joined: Sun Mar 01, 2009 11:30 pm

Postby richardk » Mon Mar 02, 2009 4:57 am

You need mod_proxy (P) because the request goes to a different (sub) domain and server.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(bookings|cname)(/(.*))?$ http://$1.example.com/$3 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 23 guests

cron