![如果在 URL 的任何部分发现子字符串,则重写](https://linux22.com/image/592179/%E5%A6%82%E6%9E%9C%E5%9C%A8%20URL%20%E7%9A%84%E4%BB%BB%E4%BD%95%E9%83%A8%E5%88%86%E5%8F%91%E7%8E%B0%E5%AD%90%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%E5%88%99%E9%87%8D%E5%86%99.png)
index.php?action=affiliate/registration
/affiliate/registration/
我想重写这个 URL,index.php?action=notfound
因为affiliate/registration
在 URL 的任何部分都发现了子字符串。
答案1
我会做类似的事情:
# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)(affiliate|registration)+(.*) index.php?action=notfound [QSA,L]
如果总有一个/
之前,我宁愿这样做:
# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/(affiliate|registration)+(.*) index.php?action=notfound [QSA,L]
如果总有一个/
之后,我宁愿这样做:
# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)(affiliate|registration)+/(.*) index.php?action=notfound [QSA,L]
如果总有/
前后之分,我宁愿这样做:
# Don't rewrite if the request is for a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/(affiliate|registration)+/(.*) index.php?action=notfound [QSA,L]