2012-06-02 26 views
1

我在這個網站獲得一個無限循環 - http://www.salesmelbourne.com的.htaccess - 無限循環

下面

是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
# 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]