Search code examples
apache.htaccessmod-rewrite

How to prevent rewrite .htaccess file conflict problem


RewriteEngine on

RewriteRule ^([^/\.]+)/?$ category.php?slug=$1
RewriteRule ^([^/\.]+)/([^/\.]+)$ product-details.php?slug1=$1&slug=$2

RewriteRule ^([^/\.]+)/?$ infrastructure-details.php?slug=$1

what I have already tried This is my htaccess file. problem is when I am trying to execute (infrastructure-details.php?slug=$1) its move to (category.php?slug=$1) conflict with first rule of htaccess.

I tired multiple rewrite methods but its not working. Please help to solve this issue.


Solution

  • Options -MultiViews
    RewriteEngine on
    RewriteRule ^infrastructure/([^/]+)$ infrastructure-details.php?slug=$1 [L]
    RewriteRule ^([^/\.]+)/?$ category.php?slug=$1 [L]
    RewriteRule ^([^/\.]+)/([^/\.]+)$ product-details.php?slug1=$1&slug=$2 [L]
    

    This is work fine for me. (infrastructure-details.php?slug=$1 [L]) put on top.