【发布时间】:2016-02-03 15:13:50
【问题描述】:
我想在我的 .htaccess 文件中添加一个不遵循 Wordpress 默认规则的规则。
一切都是这样的:
1- /course/(:any)
必须重定向到这个:
2- /course/?slug=$1
但我想将 URL 保持在 1 中,不带查询字符串。
我尝试的一切要么给我一个内部服务器错误,要么不符合规则。这就是我得到的,只是被忽略了(因为 wordpress 向我显示了“找不到页面”消息)。生成的 URL 就像 http://localhost/bethmoda/courses/?slug 没有参数并更改 URL
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/course/(.*)$ /bethmoda/course?slug=$2 [L]
RewriteBase /bethmoda/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /bethmoda/index.php [L]
</IfModule>
# END WordPress
我该怎么做?
【问题讨论】:
-
抱歉,我没有复制我的 htaccess 内容。现在正在编辑
标签: php wordpress apache .htaccess mod-rewrite