htaccess redirect if URL contains a certain string

前端 未结 4 1414
挽巷
挽巷 2020-11-30 00:35

How would I write a .htaccess redirect rule if the URL contains a certain word?

e.g. if it contains foobar then redirect to index.php

4条回答
  •  孤街浪徒
    2020-11-30 01:35

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/foobar/i$ index.php [NE,L]
    

提交回复
热议问题