PDA

View Full Version : mod_rewrite expert...


enchen
02-14-06, 08:49 AM
I'm including various files through index.php in a way that most pages have a URl like this:

index.php?choice=$var1&Some_ID=$var2&Some_Title=$var3

Below is a copy of my .htaccess which is working, but it doesn't look pretty, and soner or later I suspect there will be some issues...


RewriteEngine on

RewriteRule a(.*)/(.*)\.html$ ?choice=article&aid=$1&pt=$2

RewriteRule accommodation\.html$ ?choice=accommodation
RewriteRule more(.*)/(.*)\.html$ ?choice=accommodation&bid=$1&pt=$2

RewriteRule booking\.html$ ?choice=booking
RewriteRule booking/(.*)\.html$ ?choice=booking&action=$1

RewriteRule contact\.html$ ?choice=contact
RewriteRule contact/(.*)\.html$ ?choice=contact&action=$1

RewriteRule dloads\.html$ ?choice=dloads
RewriteRule d(.*)/(.*)\.html$ ?choice=dloads&did=$1&pt=$2

RewriteRule no-dice\.html$ ?choice=no-dice

RewriteRule poll-(.*)\.html$ ?choice=polls&action=$1

RewriteRule s(.*)/(.*)\.html$ ?choice=section&sid=$1&pt=$2

RewriteRule search\.html$ ?choice=search

RewriteRule sitemap\.html$ ?choice=sitemap

RewriteRule (.*)/tellafriend\.html$ ?choice=tellafriend&pt=$1

RewriteRule weblinks\.html$ ?choice=weblinks
RewriteRule w(.*)/(.*)\.html$ ?choice=weblinks&wid=$1&pt=$2


If someone knows how I could make this more logical and cleaner I would be the happiest man on earth today (as in today)... ;)

I suppose a RewriteCond or 2 would make a hugh difference, but as I'm not an Apache mod_rewrite expert this is way out of my league :(

End User
02-14-06, 10:31 AM
Below is a copy of my .htaccess which is working,
Sometimes the htaccess file can get pretty hairy, but that's often the case. If it's working, count your blessings and move on. :)

enchen
02-14-06, 10:45 AM
Well... You're probably right, but it would be nice though to have something a little bit less hairy :rolleyes:

I'll do some gogling and see if I can make it a little bit better....

A real substitute would be very much appreciated as well.