【发布时间】:2015-10-05 15:05:56
【问题描述】:
我当前的 page-url 如下所示,
http://localhost/testWP/?mode=home
但我想让网址如下:
http://localhost/testWP/mode/home
- 如何编写适当的
.htaccess-文件来将其变为现实?
【问题讨论】:
标签: php wordpress .htaccess url url-rewriting
我当前的 page-url 如下所示,
http://localhost/testWP/?mode=home
但我想让网址如下:
http://localhost/testWP/mode/home
.htaccess-文件来将其变为现实?【问题讨论】:
标签: php wordpress .htaccess url url-rewriting
尝试将这些规则添加到您的文档根目录:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+testWP/?\?mode=([^&\ ]+)
RewriteRule ^ /testWP/mode/%1? [L,R]
RewriteRule ^testWP/mode/(.+)$ /testWP/?mode=$1 [L]
请注意,如果您更改了您的 URL 基础(在您的问题中,它似乎是 /testWP/),您需要调整规则以反映您所做的任何更改,将 testWP 替换为适当的内容。
【讨论】: