如何使用htaccess文件将像"http://www.example.com/pathstring=something“这样的url重定向到错误页面。"http://www.example.com/path“这是url的一部分,"string=something”是查询字符串的一部分。如果有人错过了"?“在查询字符串中,页面应重定向到错误页面。
这是我的htaccess代码
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 发布于 2018-09-28 21:16:08
您可以使用它:
RewriteRule ^path([A-Za-z0-9-]+)$ /error-page.html [R=301,L]如果没有"?“在path之后,它将重定向到错误页面
发布于 2018-09-29 19:52:47
哦,好吧,http://www.example.com/pathstring=something不可能用:http://www.example.com/path?string=something重定向到重写规则。
但是,如果http://www.example.com/pathstring=something不是有效URL,且.htaccess中的路径没有重写规则,则可以将所有未找到的页面重定向到404页面。将这个添加到你的.htaccess中
RewriteEngine On
ErrorDocument 404 /my-404-page.html https://stackoverflow.com/questions/52556028
复制相似问题