I need the url from
localhost/project/category?c=electronics
to
localhost/project/category/electronics
I have tried
RewriteRule ^category/([^/\.] )?$ /category.php?c=$1 [L]
RewriteRule ^category/ ?$ /category.php?c=$1 [NC,L]
CodePudding user response:
With your shown samples and attempts please try following htaccess rules. Please do clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteBase /
##External redirect to url change in browser.
RewriteCond %{THE_REQUEST} \s/(project/category)\.php\?c=(\S )\s [NC]
RewriteRule ^ /%1/%2? [R=301,L]
##Internal rewrite to category.php in backend.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ $1/$2.php?c=$3 [QSA,L]
CodePudding user response:
RewriteEngine on
RewriteBase /
RewriteRule ^project/category/([0-9a-z] )$ /project/category?c=$1 [L]
Why is "project/" missing in your original try ?
You have to specify the full path. You can try this simple rewriteRule wich should works.