2015-09-27 23 views
1

我目前正试图在我的Apache服务器上安装Anchor CMS无法让Anchor CMS重写工作

我已成功将其部署到服务器。也就是说,当我去www.domain.com时,我接受默认主题的首页和测试帖子:)

但是,如果我尝试点击帖子,或者转到管理区域,我收到如下错误:

未找到:在此服务器上未找到请求的URL/posts/hello-world。

但是,如果我按照(在这种情况下)链接后使用直接链接,如:

www.domain.com/index.php/posts/hello-world

它工作得很好。所以,重写似乎是一个问题。

我发现了另一个问题#2酷似矿井,位于here

不幸的是,我做了同样的步骤,并没有什么作品。只是为了回顾一下,这是我的虚拟主机的外观:

<VirtualHost *:80> 
    ServerName www.domain.com 
    ServerAlias domain.com 
    DocumentRoot /var/www/domain.com/public_html 

    <Directory /var/www/domain.com/public_html> 
     AllowOverride All 
     Require all granted 
    </Dictory> 
</VirtualHost> 

这是我的锚CMS config.app文件的外观:

return array(
    'url' => '/', 
    'index' => '', 

    ...(rest of the data here)... 

由于documentation美国在这个默认使用空指数案件。

我的.htaccess目前看起来是这样的:

Options -indexes 

<IfModule mod_rewrite.c> 
     RewriteEngine On 
     RewriteBase/

     # Allow any files or directories that exist to be displayed directly 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 

     # Rewrite all other URLs to index.php/URL 
     RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
     ErrorDocument 404 index.php 
</IfModule> 

它位于文档根目录“的public_html”

可悲的是,即使配置了这些事情,我仍然得到“未找到”错误。我真的不知道从哪里这里:(

编辑去

Options -indexes 

<IfModule mod_rewrite.c> 
     RewriteEngine On 

     RewriteRule^http://google.com [R,L] 

     RewriteBase/

     # Allow any files or directories that exist to be displayed directly 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 

     # Rewrite all other URLs to index.php/URL 
     RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
     ErrorDocument 404 index.php 
</IfModule> 

我试图把在一般重写.htaccess文件,而且好像它没有被执行: 。

+1

你能检查一下htaccess是否真的被处理? – hjpotter92

+0

嘿@ hjpotter92! :)对于这个愚蠢的问题感到抱歉,但我对通常的Web开发和服务器使用情况颇为陌生。我如何检查是否正在处理htaccess? :) – CodingBeagle

+0

进行一般重写,将您重定向到其他页面:'RewriteRule^http://google.com [R,L]'。它应该超过所有其他规则,就在'RewriteEngine On'指令后面。 – hjpotter92

回答

2

看来,mod-rewrite没有被加载

请参阅您的服务器配置文件(httpd.conf)应该有一个声明如下:

LoadModule rewrite_module modules/mod_rewrite.so 

如果行以#开头,请删除#字符。您也可以使用命令:

a2enmod rewrite 

另外,尽量您Rewrite。外面转移IfModule块。

Options -indexes 

RewriteEngine On 

RewriteBase/

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# Rewrite all other URLs to index.php/URL 
RewriteRule ^(.*)$ index.php/$1 [L] 
+0

这是现货! :)的确,mod-rewrite没有被加载!我已经在使用mod-rewrite的服务器上建立了一个网站,但是我注意到LoadModule行出现在该网站自己的VirtualHost指令中!我没有在全球应用它。卫生署!这样做,并重新启动Apache服务器做了诀窍:)非常感谢你! – CodingBeagle