.htaccess rewrite regex: match anything but “index”

后端 未结 3 1878
孤城傲影
孤城傲影 2021-02-20 00:31

I\'m trying to create a rule used in a .htaccess file to match anything but a particular string, in this case: index.

I thought that it sho

3条回答
  •  礼貌的吻别
    2021-02-20 00:43

    You can use RewriteConds to do this, for example:

    RewriteCond %{REQUEST_URI} !^index
    RewriteRule (.*) index.php?what=$1
    

    That will rewrite every URL which doesn't start by index. If you want it to avoid it anywhere in the URL, remove the ^

提交回复
热议问题