【发布时间】:2016-04-23 20:18:01
【问题描述】:
我要做的是将所有不存在的 URL 重定向到 index.php?q=%URL%,例如:
www.example.com/ggg 将重定向到 www.example.com/index.php?q=ggg
但是,我希望地址栏仍然显示 www.example.com/ggg
到目前为止我得到的是:
Options +FollowSymLinks
RewriteEngine On
# redirect all requests to non-existing resources to special handler
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/? /index.php?q=$1 [L,NC,R]
但它一直在更改地址栏,而且我不确定它是否一直有效。
有什么建议吗? 谢谢
【问题讨论】:
-
实际上我想重定向所有错误页面,而不仅仅是 404。谢谢
标签: apache .htaccess mod-rewrite redirect url-rewriting