test.com/sitename/index.php > test.com/pages.php?s=sitena

Using mod_rewrite to handle various content issues

test.com/sitename/index.php > test.com/pages.php?s=sitena

Postby aaroncornish » Tue Jul 15, 2008 1:39 am

Hi Guys

Not sure if this is possible

I am making 4 or 5 different versions of the same site. They will all use the same php files but with different database content and images depending on the URL

The URL will be in the following format http://test.com/sitename/page?variables=blahblah

The system will need to access the files in the main root www.

So the backend URL would actually be more like index.php?sitename=sitename&othervariables=blahblah

I dont want to have to make a redirect rule for every page on every version of the site

Is there anyway I can do this using a blanket rule. I dont making one rule for each site - as there are only a few

Thanks in advance
Posts: 1
Joined: Tue Jul 15, 2008 1:28 am

Postby richardk » Tue Jul 15, 2008 9:19 am

Are the document roots of the domains the same?
Where are you storing the actual files?

If the document roots are the same, and you store the files in /files, you can try the following in a .htaccess file in your document root
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([^/]+)(/(.*))?$ /files/$3?sitename=$1 [QSA,L]

A request for /c/page.php?a=b would rewrite to /files/page.php?sitename=c&a=b.
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Return to Content

Who is online

Users browsing this forum: No registered users and 1 guest