سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top