Jigar Pancholi
Jigar Pancholi

Reputation: 1249

Apache Rewrite rule doesn't work properly

I have written rewrite rule in .htaccess file as below:

<IfModule mod_rewrite.c>

Options +FollowSymLinks
RewriteEngine on
RewriteRule index/cat/(.*)/ index.php?cat=$1

</IfModule>

But this rule doesn't work. I have this url /index.php?cat=auto%20loan and I want to change to /cat/auto-loan/.

So if you have any idea then please let me know.

Upvotes: 0

Views: 50

Answers (1)

Saral
Saral

Reputation: 1160

Use this code

RewriteRule ^cat/(.*)/?$ index.php?cat=$1 [L,NC]

I have made forward slash at the end optional. You should not make it optional to avoid duplicate content issue(SEO) such as RewriteRule ^cat/(.*)$ index.php?cat=$1 or RewriteRule ^cat/(.*)/$ index.php?cat=$1. Choose a format and stick to it.

Upvotes: 1

Related Questions