I am working on a PHP application, in which I need to use forward slash in place of question mark in get request. Like:
www.example.com/article?aid=10&aname=my-article
should be changed to
www.example.com/article/10/my-article
Following is my .htaccess:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^articles/(.*)$ articles?q=$1 [L,QSA,B]
I have tried a lot, but not able to find solution. How can this can be done?
You can use this rule to rewrite /article/foo/bar to /article?aid=foo&aname=bar Add the following right bellow RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^article/([^/]*)/([^/]+)/?$ /article?aid=$1&aname=$2 [L,QSA,B]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With