Aviran
Aviran

Reputation: 5458

.htaccess redirection rules with parameter rewrite

I have the following .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Which redirects every server/path request to server/path.php file.

I want to add one more specific rule, to redirect everything of the form /item/id to /item.php?var=id

Can I make it work together?

Appreciate the help.

Upvotes: 0

Views: 14

Answers (1)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try with below rule,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)$ $1.php?var=$2 [NC,L]

Upvotes: 1

Related Questions