Reputation: 1437
I am trying to rewrite the following url
http://localhost/foldername/index.php?url=writeboard/index&step=1&id=1
to
http://localhost/foldername/writeboard/index/step/1/id/1
Code is
RewriteRule ^(.+?)(?:/(step)/([0-9]+))?/?$ index.php?url=$1&$2=$3 [NC,L,QSA]
I tried with
RewriteRule ^(.+?)(?:/(step)/([0-9]+))(?:/(id)/([0-9]+))?/?$ index.php?url=$1&$2=$3&$4=$5 [NC,L,QSA]
it works but when the url becomes http://localhost/foldername/writeboard/index
then I am getting 404.
Upvotes: 1
Views: 54
Reputation: 784898
This rule should work:
RewriteRule ^(.+?)/(step)/([0-9]+)/(id)/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ index.php?url=$1 [NC,L,QSA]
Upvotes: 1