Reputation: 849
I have some difficulties to create a simply htaccess for url rewriting.
What I would like is url with 3 parameters :
www.example.com => index.php
www.example.com/module/ => index.php?module=$1
www.example.com/module/action/ => index.php?module=$1&action=$2
www.example.com/module/action/1 => index.php?module=$1&action=$2¶ms=$3
I did that with many tutorials, but when I try with the last one, it's failed
RewriteRule ^web/([^/]*)$ index.php?module=$1 [L,QSA]
RewriteRule ^web/([^/]*)/(.*[^/])$ index.php?module=$1&action=$2 [L,QSA]
RewriteRule ^web/([^/]*)/(.*[^/])/([0-9]*)$ index.php?module=$1&action=$2¶ms=$3 [L,QSA]
Someone could help me ?
Thanks
Bouffe
Upvotes: 1
Views: 52
Reputation: 143846
The .*
part of your second expression is gobbling up anything after /action/
so you need to limit it the same as the one right before the /
and use the +
instead of *
:
RewriteRule ^web/([^/]+)$ index.php?module=$1 [L,QSA]
RewriteRule ^web/([^/]+)/([^/]+)/?$ index.php?module=$1&action=$2 [L,QSA]
RewriteRule ^web/([^/]+)/([^/]+)/([0-9]+)/?$ index.php?module=$1&action=$2¶ms=$3 [L,QSA]
Upvotes: 1