我有htaccess文件(下面的代码),在两个服务器上使用相同的域名更改。它在一个工作正常,但在另一个上给出一个Redirect Loop问题。唯一的区别是,在一台服务器上我使用的是域名,而在另一台服务器上我使用的是专用IP地址
代码:
工作代码:::
RewriteEngine on
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
##below 7 lines used in live server
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
RewriteRule ^admin/$ admin/index.php
RewriteRule ^$ home/ [R]
RewriteRule ^home/$ page/index.php [L]
RewriteRule ^blog/$ blog/index.php [L]
RewriteRule ^forms/$ site-forms/index.php [L]
RewriteRule ^media/xmlfeeds/$ page/index.php
RewriteRule ^([a-z]+)(\/?)$ page/index.php [NC,QSA,L]
不工作代码:::
RewriteEngine on
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
##below 7 lines used in live server
RewriteBase /
RewriteCond %{HTTP_HOST} ^108\.175\.155\.54
RewriteRule ^(.*)$ http://108.175.155.54/$1 [R=permanent,L]
RewriteRule ^admin/$ admin/index.php
RewriteRule ^$ home/ [R]
RewriteRule ^home/$ page/index.php [L]
RewriteRule ^blog/$ blog/index.php [L]
RewriteRule ^forms/$ site-forms/index.php [L]
RewriteRule ^media/xmlfeeds/$ page/index.php
RewriteRule ^([a-z]+)(\/?)$ page/index.php [NC,QSA,L]
谢谢。
答案 0 :(得分:2)
循环由以下两行引起:
RewriteCond %{HTTP_HOST} ^108\.175\.155\.54
RewriteRule ^(.*)$ http://108.175.155.54/$1 [R=permanent,L]
这些说,"如果主机是108.175.155.54,那么重定向到108.175.155.54。"
所以在实时服务器上注释这些行。如果您有域名,则可以取消注释并改为使用域名。