views:

96

answers:

3

Hello i am having a issue with htaccess mod_rewrite, maybe someone here could point in the the right direction.

my site has 1 main file [index.php] all the navigation is done by passing vars in the url string eg

index.php?page=about

this is working ok with my .htaccess [below]

domain.com/about

some of the pages have a second variable eg

index.php?page=event&eventID=42

this works too with the .htaccess below

domain.com/event/42

my problem is that I have other other pages that require vars too eg

index.php?page=news&newsID=4 domain.com/news/42

index.php?page=map&venueID=4 domain.com/map/42

Is it possible to do this ?

Thanks in advance

.k

.htaccess

Options +FollowSymLinks

RewriteEngine On

RewriteRule ^([^/\.]+)/*$ /index.php?page=$1 [L]
RewriteRule ^([^/\.]+)/*([^/\.]+)/*$ /index.php?page=$1&eventType=$2 [L]
+3  A: 

Sure, just do

RewriteRule ^([^/\.]+)/*$ /index.php?page=$1 [L]
RewriteRule ^event/([^/\.]+)/*$ /index.php?page=event&eventType=$1 [L]
RewriteRule ^news/([^/\.]+)/*$ /index.php?page=news&newsID=$1 [L]
RewriteRule ^map/([^/\.]+)/*$ /index.php?page=map&venueID=$1 [L]
chaos
Keet
Oops, right. Editing per...
chaos
+1  A: 

Try these rules:

RewriteRule ^([^/.]+)/?$ /index.php?page=$1 [L]
RewriteRule ^map/([^/.]+)/?$ /index.php?page=map&venueID=$1 [L]
RewriteRule ^([^/.]+)/([^/.]+)/?$ /index.php?page=$1&$1ID=$2 [L]

Your /map/… URLs need a separate rule as the URL parameter is not mapID but venueID. But the rest should be covered by the third rule. But it would certainly be easier if you call the ID parameter just id.

Gumbo
thanks, was think that about the 'ID' that but the site is already code, just adding the .htacess now.the last rule is great might just change venueID to mapID on the site
Keet
A: 

Please refer to below link, Hope this would be helpful.

http://www.generateit.net/mod-rewrite/

Naser