Assigning variable as "directory" in url

Discuss practical ways rearrange URLs using mod_rewrite.

Assigning variable as "directory" in url

Postby Genjitsu » Wed Oct 22, 2008 6:33 pm

Ok, so I have a site that has two different layouts, let's call one male and the other female. Currently I have it set up so that you can change the layout of the site by adding a variable to whatever page is pulled up. So for example:

display.php?site=male
display.php?site=female

Is there a way to use mod_rewrite to have it appended by typing it as a directory, regardless of which file is pulled up? In other words, if I had another file, listing.php

listing.php?site=male&othervariables = blah
turns into
male/listing.php?othervariables=blah

I hope this doesn't sound too confusing, I just don't want to create two copies of what's basically the same site by making actual directories named male and female. Thanks for any help!
Genjitsu
 
Posts: 1
Joined: Wed Oct 22, 2008 6:27 pm

Postby richardk » Thu Oct 23, 2008 5:55 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^(female|male)(/(.*))?$ /$3?site=$1 [QSA,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 8 guests

cron