.htaccess - 无限循环

时间:2012-06-02 02:30:53

标签: .htaccess

我在这个网站上获得了一个无限循环 - http://www.salesmelbourne.com

下面是.htaccess,我知道问题出现在最后4行 - 我认为是这样 - 有些人可以提供一些建议...... thx

 php_value session.gc_maxlifetime 259200
 php_flag register_globals off
 php_flag zlib.output_compression on
 php_flag output_compression_level 6

 <Files *>
 Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
 Header set Expires: 0
 Header set Pragma: no-cache
 </Files>

 # File Upload 25MB
 php_value post_max_size 20M
 php_value upload_max_filesize 20M
 php_value max_execution_time 1000

 # use utf-8 encoding for anything served text/plain or text/html
 AddDefaultCharset utf-8

 # force utf-8 for a number of file formats
 AddCharset utf-8 .html .css .js .xml .json .rss .php
 RewriteEngine on
 RewriteCond %{HTTP_HOST} !^www\. [NC]
 RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L]

 # Internally redirect all pages to index.php
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^/ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]
 RewriteRule . index.php [L]

1 个答案:

答案 0 :(得分:1)

# Internally redirect all pages to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]
RewriteRule . index.php [L]

第2行(从最后)到底是什么?无论如何都不应该工作,因为RewriteRule中的URL模式以无前导斜杠开头,但你在那里(^/ajax/pages/(.*)$)。

由于我不知道该特定规则是如何工作的,因此有两种可能的解决方案(两种方法都可行 - 所有这些都与前面提到的一致 - 它是否需要这两个条件才能正常运行):

# I have no idea how this rule is supposed to work, but assume it's the way to go
RewriteRule ^ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]

# Internally redirect all pages to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

或者像这样(如果这些条件对于该规则很重要)

# I have no idea how this rule is supposed to work, but assume it's the way to go
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ajax/pages/(.*)$ /www/ajax/pages/404_error.php [R=301]

# Internally redirect all pages to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]