How to exclude base url from some rewrite rule in htaccess?

Hi everyone, I have a rewrite rule in my .htaccess file which

RewriteRule  ^([a-zA-Z0-9\-\_]+)?$  product.php?product=$1    [NC,L]

      

When I go to www.domain.com site it applies the above rule and redirects it to product.php and when www.domain.com/index.php works fine. Where am I doing wrong. Thanks to

+3


source to share


2 answers


Remove ?

in your regex that makes the whole pattern optional and excludes directories from this rule:



RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule  ^([\w-]+)/?$ product.php?product=$1 [QSA,L]

      

+3


source


<IfModule mod_rewrite.c>
Options -Indexes

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /your_project_folder_name/index.php/$1 [L]
</IfModule>

      



0


source







All Articles