无法让 Anchor CMS 重写工作
Can't get Anchor CMS rewriting to work
我目前正在尝试在我的 Apache 服务器上安装 Anchor CMS。
我已经成功部署到服务器上了。也就是说,当我转到 www.domain.com 时,迎接我的是默认主题首页和测试 post :)
但是,如果我尝试单击 post,或转到管理区域,我会收到如下错误消息:
Not Found: The requested URL /posts/hello-world was not found on this server.
但是,如果我按照(在这种情况下)post link 使用直接 link,例如:
www.domain.com/index.php/posts/hello-world
它工作得很好。所以,看来是重写的问题。
我在 Whosebug 上发现了另一个和我一模一样的问题,位于
不幸的是,我做了同样的步骤,但没有任何效果。回顾一下,这就是我的 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>
这就是我的 Anchor 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/ [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/ [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/ [L]
我目前正在尝试在我的 Apache 服务器上安装 Anchor CMS。
我已经成功部署到服务器上了。也就是说,当我转到 www.domain.com 时,迎接我的是默认主题首页和测试 post :)
但是,如果我尝试单击 post,或转到管理区域,我会收到如下错误消息:
Not Found: The requested URL /posts/hello-world was not found on this server.
但是,如果我按照(在这种情况下)post link 使用直接 link,例如:
www.domain.com/index.php/posts/hello-world
它工作得很好。所以,看来是重写的问题。
我在 Whosebug 上发现了另一个和我一模一样的问题,位于
不幸的是,我做了同样的步骤,但没有任何效果。回顾一下,这就是我的 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>
这就是我的 Anchor 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/ [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/ [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/ [L]