Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php htaccess在一台服务器上工作正常,在另一台服务器上导致重定向循环_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php htaccess在一台服务器上工作正常,在另一台服务器上导致重定向循环

Php htaccess在一台服务器上工作正常,在另一台服务器上导致重定向循环,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我有htaccess文件(代码如下),在两个域名更改的服务器上使用相同的文件。它在其中一个上运行良好,但在另一个上出现重定向循环问题。唯一的区别是,在一台服务器上我使用域名,在另一台服务器上我使用专用IP地址 代码: 工作代码::: RewriteEngine on # Use PHP5 Single php.ini as default AddHandler application/x-httpd-php5s .php # For security reasons, Option follo

我有htaccess文件(代码如下),在两个域名更改的服务器上使用相同的文件。它在其中一个上运行良好,但在另一个上出现重定向循环问题。唯一的区别是,在一台服务器上我使用域名,在另一台服务器上我使用专用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]
不工作代码:::

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]

谢谢。

循环是由以下两行引起的:

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。”


因此,在实时服务器上对这些行进行注释。当您有域名时,您可以取消对它们的注释,改为使用域。

因此,在第二种情况下,请求是使用浏览器URL行中的原始ip地址完成的?是的。我得一直等到安装结束。谢谢你,迈克。我按建议做了,但现在下载了一个未知文件类型的文件。