我决定放弃Wordpress,转而搬到Pico CMS。
现在,我正在为正确地完成URL重写而奋斗。
我成功地重写了eg的查询字符串。https://www.example.org?page to https://www.example.org/page使用RewriteRule ^(.*) ?$1 [L],但如果是查询字符串,那么现在也要重写它。
示例:
如果请求https://www.example.org?page,它将加载得很好,但我希望将其重写为https://www.example.org/page --至少在地址栏中是这样的。
我试过几种不同的方法,但都没有用。我不擅长正则表达式..。
RewriteCond %{QUERY_STRING} !^$ RewriteRule ^\\?/(.*)$ $1
不是
RewriteRule (^\?$) https://tanghus.net/$1 [NC,R=301,L] RewriteRule ^.*$ https://tanghus.net/? [NC,R=301,L]
无骰子
RewriteCond %{QUERY_STRING} . RewriteRule ^$ %{QUERY_STRING} [R,L]
Pfff
RewriteCond %{THE_REQUEST} \?\sHTTP [NC] RewriteRule ^ %{REQUEST_URI} [L,R]
放弃:(
发布于 2018-03-19 14:53:50
您可以使用此规则
RewriteEngine on
# externally redirect from /?page to /page
RewriteCond %{THE_REQUEST} /\?([^\s]+) [NC]
RewriteRule ^/?$ /%1? [L,R]
# internally map /page to /?page
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?(.+)$ /?$1 [L]https://stackoverflow.com/questions/49353167
复制相似问题