Trying to put an exception to RewriteRule in .htaccess

前端 未结 1 423
余生分开走
余生分开走 2020-12-10 02:56

I am redirecting all requests like so:

RewriteRule ^sitemap.xml$ sitemap.php?/ [QSA,L]

# the line below is the one I\'m having trouble with

RewriteCond %{R         


        
相关标签:
1条回答
  • So you just need to ignore http://yourdomain.com/market-reports (in addition to files/directories?). You should be fine with:

    RewriteCond %{REQUEST_URI} !^/market-reports/?$
    

    This will (not) match "http://yourdomain.com/market-reports" as well as "http://yourdomain.com/market-reports/" as the question mark "?", in the Perl Compatible Regular Expression vocabulary that mod_rewrite uses, makes the match optional (a wildcard) before the end of the string anchor, which is represented with the literal dollar sign "$".

    The "^" symbol acts as an anchor matching the beginning of the string and the "!" negates the match, so that any string URL that does not match the rest of the expression will be rewritten to the other specified rules. See mod_rewrite regex vocabulary

    0 讨论(0)
提交回复
热议问题