Search code examples
.htaccessmod-rewritehttp-redirectconflict

.htaccess RewriteRule and Redirect conflict


Have this rule

RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]

And this redirects

Redirect 301    /shops/ /magaziny
Redirect 301    /contact    /kontakty
Redirect 301    /about /o-nas
Redirect 301    /kakkupit   /kak-kupit

They conflicts with each other and for example when I go to http://domain.do/shops/ I have:

http://domain.do/magaziny?module=PageView&page_url=shops

How could I fix this ?


Solution

  • You'll need to add a condition to your RewriteRule so that it won't execute if shops, contact, about or kakkupit is in the url. It would look something like this:

    Redirect 301    /shops/ /magaziny
    Redirect 301    /contact    /kontakty
    Redirect 301    /about /o-nas
    Redirect 301    /kakkupit   /kak-kupit
    
    RewriteCond %{REQUEST_URI} !(shops|contact|about|kakkupit)\b
    RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]