Domanda

RewriteCond %{REQUEST_URI} (.*)Products/(.*) [NC]
RewriteRule .* Products/viewproduct.php?category_name=%2 [L]

I am trying to Get category name but it shows viewproduct.php

È stato utile?

Soluzione

You can use this rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule Products/(.+)$ Products/viewproduct.php?category_name=$1 [L,NC,QSA]

Problem is that your rule is executing twice. 1st time for /Products/abc/ and 2nd time for `/Products/viewProduct.php/ URL since your pattern is matching both times. RewriteCond above will stop this behavior.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top