views:

38

answers:

2

I have these urls:

index.php?area=guilds
index.php?area=guilds&page=create
index.php?area=guilds&page=view&name=The+Unit

Could I have only 1 rewrite rule for this somehow?

/guilds
/guilds/create
/guilds/view/The+Unit
A: 

Try these rules:

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^[^/]+$ index.php?area=$0 [L]
RewriteRule ^([^/]+)/([^/]+)$ index.php?area=$1&page=$2 [L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ index.php?area=$1&page=$2&name=$3 [L]

The first rule is to avoid that URLs are rewritten that already can be mapped to an existing file. The other rules reflect your three cases.

Gumbo
A: 

This one should work :

RewriteRule    /(.+)(?:/(.+))?(?:/(.+))?   index.php?area=$1&page=$2&name=$3
Pikrass
dont forget to turn the rewrite engine on in the htaccess :DRewriteEngine on
danp