1

这是我所做的并且效果很好:

#redirect subdomains to controller
RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
RewriteRule ^([a-zA-Z0-9-_]*)$ blog.php?blog_uid=%1 [L,QSA]

现在我想重定向

 http://example.domain.com/post-123.html

blog.php?blog_id=example&post_id=123

但这不起作用:

RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com$ [NC]
RewriteRule ^([a-zA-Z0-9-_]*)/post-([0-9]+)\.html$ blog.php?blog_uid=%1&post_id=%2 [L,QSA]

怎么做?实际上如何将此类子域请求重定向到重写条件(它不是真实页面)。

4

2 回答 2

0

Try this one.

RewriteEngine On
RewriteRule ^post-([^/]*)\.html$ /blog.php?blog_id=example&post_id=$1 [L]
于 2012-12-06T15:13:07.920 回答
0

请改用此规则:

RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
RewriteRule ^post-([0-9]+)\.html$ /blog.php?blog_id=%1&post_id=$1 [NC,L,QSA]
于 2012-12-06T17:47:43.237 回答