我有一个简单的 PyroCMS 2.2.1 站点,它使用 Apache 上的默认主页和登录系统(我认为是 2.2.25!)。在我的本地环境(OS X 10.7/Apache 2.2.22)中,一切正常。我们在让 mod_rewrite 工作时遇到了一些问题,但现在 URL 是干净的,并且似乎可以工作——除了我们无法使用表单登录。
问题似乎与登录请求有关。发送请求时登录不起作用,例如:
http://www.ourdomain.com/users/login?email=admin&password=123456&btnLogin=Login
但!当它包含 index.php 时它确实有效。像这样:
http://games.coe.uky.edu/index.php/users/login?email=admin&password=123456&btnLogin=Login
我可以通过将 index.php 添加到表单操作来强制它,但我确信这不是必需的。我确实查看了几个 CodeIgniter 和 PyroCMS 论坛帖子,但没有找到解决方案。
更多背景:在 Apache 中启用 mod_rewrite 后,我们调整了 system/cms/config/config.php 以显示:
$config['index_page'] = '';
这是我们的 .htaccess 文件的副本:
# Multiple Environment config
# Set this to development, staging or production
SetEnv PYRO_ENV development
<IfModule mod_rewrite.c>
# Make sure directory listing is disabled
Options +FollowSymLinks -Indexes
# disable the Apache MultiViews directive if it is enabled on the server. It plays havoc with URL rewriting
Options -MultiViews
RewriteEngine on
# Automatically determine and set the PYRO_ENV variable
#RewriteCond %{HTTP_HOST} ^local.domain.com$
#RewriteRule (.*) $1 [E=PYRO_ENV:development]
#RewriteCond %{HTTP_HOST} ^stage.domain.com$
#RewriteRule (.*) $1 [E=PYRO_ENV:staging]
#RewriteCond %{HTTP_HOST} ^domain.com$
#RewriteRule (.*) $1 [E=PYRO_ENV:production]
# NOTICE: If you get a 404 play with combinations of the following commented out lines
#AllowOverride All
#RewriteBase /home/supers/htdocs
# Restrict your site to only one domain
# !important USE ONLY ONE OPTION
# Option 1: To rewrite "www.domain.com -> domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Option 2: To rewrite "domain.com -> www.domain.com" uncomment the following lines.
#RewriteCond %{HTTPS} !=on
#RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
#RewriteCond %{HTTP_HOST} (.+)$ [NC]
#RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Keep people out of codeigniter directory and Git/Mercurial data
RedirectMatch 403 ^/.*/(system/cms/cache|system/codeigniter|system/cms/config|system/cms/logs|\.git|\.hg).*$
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
</IfModule>
谢谢!