我搜索了这个问题,但只遇到了无法满足我的要求的非常具体的答案。
我的 URL 现在看起来像这样:https://example.eu/?action=changepassword并且我希望它看起来像这样:https://example.eu/changepassword所以文本?action=被删除。
我搜索了这个问题,但只遇到了无法满足我的要求的非常具体的答案。
我的 URL 现在看起来像这样:https://example.eu/?action=changepassword并且我希望它看起来像这样:https://example.eu/changepassword所以文本?action=被删除。
使用您显示的示例,请尝试遵循 htaccess 规则文件。还请确保在测试您的 URL 之前清除您的浏览器缓存。
RewriteEngine ON
##External redirect rules here....
RewriteCond %{THE_REQUEST} \s/?\?action=(\S+)\s [NC]
RewriteRule ^ %1? [R=301,L]
##Internal rewrite rules to handle query string in backend.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /?action=$1 [L]