我目前正在尝试安装锚CMS在我的Apache服务器上。
我已经成功地将它部署到服务器。也就是说,当我访问www.domain.com时,迎接我的是默认主题的首页和测试文章:)
但是,如果我尝试点击帖子,或者转到管理区域,我得到一个错误,如:
Not Found:请求的URL/posts/hello-world在此服务器上找不到。
但是,如果我使用直接链接跟随post链接(在本例中),例如:
www.domain.com/index.php/posts/hello-world
工作完全正常。所以,这似乎是重写的问题。
我在Stackoverflow上发现了另一个问题,就像我的一样,位于这里
不幸的是,我做了相同的步骤,没有工作。回顾一下,这是我的VirtualHost的样子:
<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配置。应用程序文件看起来:
return array(
'url' => '/',
'index' => '',
...(rest of the data here)...
如文档所述,在默认情况下使用空索引。
我的。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"
遗憾的是,即使配置了这些东西,我仍然得到"Not Found"错误。我真的不知道从这里要去哪里:
编辑
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文件,它似乎没有被执行:
显示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]