2014-11-03 20 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

相关问题