【发布时间】:2013-02-10 13:09:19
【问题描述】:
我正在尝试将一些参数重写为漂亮的链接,但仅适用于子域/文件夹。不幸的是,我无法让它工作,也可能是因为之前还有一些其他的重写......
这是我的代码:
<IfModule mod_rewrite.c>
# NON-WWW TO WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# WORDPRESS-BLOG
Options +FollowSymlinks
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# REDIRECT FOR SUBDOMAIN
RewriteCond %{HTTP_HOST} ^subdomain.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)(?:/)?$ index.php?cshort=$1 [L]
RewriteRule ^([^/.]+)/([^/.]+)(?:/)?$ /index.php?cshort=$1&cid=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)(?:/.*)?$ /index.php?cshort=$1&cid=$2&step=$3 [L]
</IfModule>
基本上只有最后一部分是我想重写的部分,以更改类似
的 URLhttp://subdomain.example.com/index.php?cshort=abc&cid=123&step=1 到 http://subdomain.example.com/abc/123/1
www.example.com 的其他重写规则不应该受到影响。不幸的是,我当前的代码只为博客和 www 做了前两个规则,但子域没有任何反应。我的代码有什么问题?
【问题讨论】: