GoDaddy上的Wordpress URL参数

时间:2011-11-11 05:27:24

标签: php wordpress mod-rewrite

我目前正在制作一个网站(http://tannernelson.me/ehs

它托管在Godaddy上,我使用wordpress作为CMS。

我希望能够:

http://tannernelson.me/ehs/school/academics/teachers/jsmith

变成

http://tannernelson.me/ehs/index.php?pagename=teachers&detail=jsmith

所以,基本上,如果网址有4个段(school / academics / teachers / jsmith),我希望最后一个是变量。所以任何网址的第四段都是变量“detail”

我当前的网址重写目前是

# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ehs/index.php [L]
Options -Multiviews

即使使用默认的WordPress .htaccess文件,它也无法以任何其他方式工作。我不知道这意味着什么,或者是什么样的请求URI。这真的令人困惑。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您现在拥有的代码意味着:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

如果请求的文件名不是!)常规文件-f,并且所请求的文件名不是({{1} })目录!然后:

-d

匹配任何单个字符(RewriteRule . /ehs/index.php [L] ),如果找到匹配项,则将网址重写为.,然后将其设为最后一条规则(/ehs/index.php),以便不要处理任何进一步的规则。

这看起来不像你想要的,但似乎有效。 [L]提供(我认为)http://tannernelson.me/ehs/school/academics/teachers/jsmith,因为我找到了自定义404未找到的网页。

尝试以下http://tannernelson.me/ehs/index.php代码:

.htaccess

我刚刚在我的Apache服务器上测试了它,它可以工作。

相关问题