2014-11-03 24 views
0

我有這個CMS成立了一家名爲localhost:5999/madison/.htaccess文件的令人費解的行動(代號內)

.htaccess文件(下面的代碼)文件夾中是在同一文件夾localhost:5999/madison/

如果在瀏覽器中,我去localhost:5999/madison/localhost:5999/madison/index.phplocalhost:5999/madison/xyz其中XYZ是任何不包含斜槓,它重定向我以下文件:localhost:5999/madison/inc/views/view-404.php

我的問題是:爲什麼?

的.htaccess代碼:

RewriteEngine On 
ExpiresActive On 

#Expire Header 
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$"> 
ExpiresDefault "now plus 7 days" 
</FilesMatch> 

ExpiresByType text/css "now plus 7 days" 
ExpiresByType text/html "now plus 7 days" 
ExpiresDefault "now plus 7 days" 

AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css 

RewriteRule ^(assets|inc) - [L] 

RewriteRule ^admin[/]?$       admin/index 

RewriteRule ^admin/edit/(.*)$     index.php?type=admin&action=edit&page=$1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^admin/(.*)$      index.php?type=admin&action=view&page=$1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^login$        index.php?action=view&type=login&%1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^forgot-password$     index.php?action=view&type=forgot-password&%1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^edit/user(/)?$      index.php?action=edit&type=user&%1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^signup(/)?$      index.php?action=edit&type=user&id=0&%1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^user/([0-9]+)(/)?     index.php?action=view&type=note&user=$1&%1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^(suggestion|comment)/([0-9]+)(/)? index.php?action=view&type=note&page=open&note_type=$1&note=$2&%1 [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^([0-9A-Za-z\-_]+)/(suggestion|comment)/([0-9]+)(/)? index.php?action=view&type=note&page=$1&note_type=$2&note=$3&%1 [L] 

#Catch All Pages 
RewriteRule ^index\.php$ - [L] 

RewriteCond %{QUERY_STRING} ^(.*)?$ 
RewriteRule ^([0-9A-Za-z\-_]+)(/)?   index.php?action=view&type=page&page=$1&%1 [L] 

回答

1

產生的問題是,因爲你是在一個子文件夾localhost:5999/madison/承載CMS(無需改動configuration file),而不是直接在localhost:5999/

要解決此問題,進行以下修改config.php在目錄:

config.php

/** 
* Server Definitions 
*/ 
define('SERVER_ABS', $_SERVER['DOCUMENT_ROOT']); 
define('SERVER_URL', 'http://'.$_SERVER['HTTP_HOST']); 

要:

/** 
* Server Definitions 
*/ 
define('SERVER_ABS', $_SERVER['DOCUMENT_ROOT'].'/madison'); 
define('SERVER_URL', 'http://'.$_SERVER['HTTP_HOST'].'/madison'); 
+0

先生,你是個天才。 – 2014-11-03 21:14:58

1

這似乎爲當前的.htaccess以外的一些自定義的404處理器所證實。

嘗試在你的.htaccess的頂部加上幾行:

DirectoryIndex index.php 
RewriteEngine On 
RewriteBase /madison/ 

,保持你的最後一條規則爲:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([\w-]+)/?$ index.php?action=view&type=page&page=$1 [L,QSA] 

然後在新的瀏覽器測試以避免舊的緩存。

+0

感謝您的建議。但是,「RewriteBase/madison /」會導致500錯誤。 – 2014-11-03 19:17:07

+0

好問題。首先,我粘貼了一切,並得到了這個錯誤。之後,我一個接一個地去除部件,直到只剩下那條線並得到了那個錯誤。這裏有一些來自error.log:「[Mon Nov 03 12:14:35.604466 2014] [core:alert] [pid 4670] [client :: 1:50074] /Applications/XAMPP/xamppfiles/htdocs/madison/.htaccess :RewriteBase帶有一個參數,即每個目錄上下文的基本URL「 – 2014-11-03 20:48:54

+0

這意味着在'RewriteBase'之後''RewriteBase/madison /'有確切的一個參數。你確定你複製了嗎?您正在使用什麼編輯器進行編輯? – anubhava 2014-11-03 21:03:16

相關問題