0

I have the following in my .htaccess which basically removes .php extensions from url and redirects user to the url without the .php extension. However, if i have a querystring for lets say account.php, it will be account?user=john&id=12, I would like my htacess code below to be abe to let convert the querystring to forwardslashes.

Any ideas how I can do this? Thanks

RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
Ahmed
  • 1,103
  • 2
  • 12
  • 36
  • 1
    Match the query string params, and include them in the redirection. Please concretize where you're stuck. – mario Sep 13 '15 at 13:09
  • possible duplicate of [How do I convert a PHP query string into a slash-based URL?](http://stackoverflow.com/q/4301481), [Yet another mod\_rewrite query -- Cannot rewrite to pretty url and keep query strings](http://stackoverflow.com/q/19142719), [htaccess rewrite rule, old URL to new](http://stackoverflow.com/q/7594697), [Rewrite URL so that query string is in path](http://stackoverflow.com/q/16020967), [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/q/20563772) – mario Sep 13 '15 at 13:21

1 Answers1

0

Create a .htaccess file with the code below

RewriteEngine on
RewriteRule product-categoryid-(.*)-productid-(.*)\.htm$ Your Root URl?categoryid=$1&productid=$2   

Your Root URl

Root URL means like wwww.google.com/

Maulik Santoki
  • 474
  • 4
  • 13