【发布时间】:2011-11-21 23:37:16
【问题描述】:
这是我的 htaccess 文件
Options +FollowSymLinks
RewriteEngine on
# For Accessing Page http://www.domain.com/news/news-details.php
RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC]
RewriteRule ^news/news-details.php$ news.php [QSA,NC,L]
# For www.domain.com it should go to the index page
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC]
RewriteRule ^(.*)$ index.php [NC,L]
当我在浏览器中输入http://www.domain.com/news/news-details.php 时,它会将我带到 index.php 页面而不是 news.php。为什么?
编辑: 检查这些规则
# For www.domain.com it should go to my-index.php page
#
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^(.*)$ my-index.php [NC,L]
# For Page URL http://www.domain.com/news/news-details.php
#
RewriteCond %{REQUEST_URI} ^/news/news\-details\.php [NC]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ my-news.php [NC,QSA,L]
【问题讨论】:
标签: .htaccess url-rewriting subdomain