mod重写 - 澄清

时间:2011-04-21 20:10:41

标签: .htaccess mod-rewrite

我的htaccess代码是

RewriteEngine on
Options +FollowSymlinks -MultiViews

# URL REWRITE
RewriteRule ^domain-name/?$ domain.php [L]
RewriteRule ^domain-name/registration/?$ domain-registration.php [L]
RewriteRule ^domain-name/price/?$ domain-price.php [L]
RewriteRule ^domain-name/security/?$ domain-security.php [L]
RewriteRule ^domain-name/features/?$ domain-features.php [L]
RewriteRule ^domain-name/faq/?$ domain-faq.php [L]
RewriteRule ^domain-name/provider/?$ domain-why-choose-us.php [L]
RewriteRule ^domain-name/free/?$ domain-free.php [L]
RewriteRule ^domain-name/transfer/?$ domain-transfer.php [L]

# 301
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

我的问题是,如果我输入http://domain.com/domain-name/free 这工作正常。但

http://www.domain.com/domain-name/free 是我原来的php文件(free.php)

如何解决这个问题?


问题已解决我的正确代码如下

RewriteEngine on
Options +FollowSymlinks -MultiViews

# 301
RewriteCond %{HTTP_HOST} ^www\.globaliway\.com$ [NC]
RewriteRule ^(.*)$ http://globaliway.com/$1 [R=301,L]

# URL REWRITE
RewriteRule ^domain-name/?$ domain.php [L]
RewriteRule ^domain-name/registration/?$ domain-registration.php [L]
RewriteRule ^domain-name/price/?$ domain-price.php [L]

1 个答案:

答案 0 :(得分:0)

我已修改您的.htaccess文件以解决一些问题,请从此处复制/粘贴包含选项行Options +FollowSymlinks -MultiViews

RewriteEngine on
Options +FollowSymlinks -MultiViews

# URL REWRITE
RewriteEngine  on
RewriteRule ^domain-name/?$ /domain.php [L,NC]
RewriteRule ^domain-name/registration/?$ /domain-registration.php [L,NC]
RewriteRule ^domain-name/price/?$ /domain-price.php [L,NC]
RewriteRule ^domain-name/security/?$ /domain-security.php [L,NC]

# 301
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]