我写了很多辅导,但都导致了相同的错误——错误500——要么服务器过载,要么CGI脚本出错。
我在Windows上使用xampp并共同配置了httpd。像这样
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
在yiimain.php改变
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'caseSensitive'=>false,
'rules'=>array(
'' => 'site/index',
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
并在根文件夹中添加. htaccess(与受保护文件夹的级别相同)
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteBase /tests/
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
但不管我写什么。htaccess,我得到这个错误。当我注释掉所有内容时,yii中的链接生成正常(没有index.php),但由于错误的服务器配置,我出现了404错误。
编辑:
error.log最后几张唱片:
[11月27日星期三11:32:31.100063 2013][core:alert][pid 9520:tid 1572][client::1:58620]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 11:32:31.372163 2013][core:alert][pid 9520:tid 1572][client::1:58621]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 11:32:34.674379 2013][core:alert][pid 9520:tid 1572][client::1:58622]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 11:32:36.587084 2013][core:alert][pid 9520:tid 1572][client::1:58623]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 11:32:54.899832 2013][core:alert][pid 9520:tid 1572][client::1:58624]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 11:54:14.056192 2013][core:alert][pid 9520:tid 1572][client::1:59297]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 11:54:14.687425 2013][core:alert][pid 9520:tid 1572][client::1:59298]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 15:53:27.459885 2013][ssl:warn][pid 11320:tid 308]AH01909:为www.example配置的RSA证书。com:443不包含与服务器名称匹配的ID[Wed Nov 27 15:53:27.525911 2013][core:warn][pid 11320:tid 308]AH00098:pid文件C:/Users/kristineg/xamps/apache/logs/httpd。pid覆盖——上次Apache运行的不干净关闭?[11月27日星期三15:53:27.588934 2013][ssl:warn][pid 11320:tid 308]AH01909:RSA证书已为www.example配置。com:443不包含与服务器名称匹配的ID[Wed Nov 27 15:53:27.625947 2013][mpm_winnt:notice][pid 11320:tid 308]AH00455:Apache/2.4。4(Win32)OpenSSL/1.0。1e PHP/5.5。1已配置--恢复正常操作[Wed Nov 27 15:53:27.625947 2013][mpm_winnt:notice][pid 11320:tid 308]AH00456:服务器构建:2013年2月23日12:42:00[Wed Nov 27 15:53:27.625947 2013][core:notice][pid 11320:tid 308]AH00094:命令行:'c:\users\kristineg\xamps\apache bin\httpd。exe-d C:/Users/kristineg/xamps/apache'[Wed Nov 27 15:53:27.627948 2013][mpm_winnt:notice][pid 11320:tid 308]AH00418:Parent:Created child process 4472[Wed Nov 27 15:53:27.998083 2013][ssl:warn][pid 4472:tid 336]AH01909:RSA证书为www.example配置。com:443不包含与服务器名称匹配的ID[Wed Nov 27 15:53:28.143138 2013][ssl:warn][pid 4472:tid 336]AH01909:RSA证书(为www.example配置)。com:443不包含与服务器名称匹配的ID[Wed Nov 27 15:53:28.186154 2013][mpm_winnt:notice][pid 4472:tid 336]AH00354:Child:启动150个工作线程。[11月27日星期三15:53:38.827074 2013][core:alert][pid 4472:tid 1640][client::1:61797]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 15:53:39.614364 2013][core:alert][pid 4472:tid 1652][client::1:61796]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 15:53:39.958491 2013][core:alert][pid 4472:tid 1640][client::1:61798]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 15:53:40.295616 2013][core:alert][pid 4472:tid 1652][client::1:61799]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许选项[Wed Nov 27 16:32:32.894114 2013][core:alert][pid 4472:tid 1640][client::1:62407]C:/Users/kristineg/xamps/htdocs/xampp/tests/。htaccess:此处不允许使用选项
我认为您没有在服务器的主配置中加载mode_rewrite
模块。首先,修改您的. htaccess
,使其看起来像这样:
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /tests/
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
如果情况好转(即没有500个错误),请参阅mainhttpd。conf
并查找一行开头如下:
#LoadModule rewrite_module ...
通过删除前导的#
取消对该行的注释,然后重新启动服务器进程。
至于“此处不允许选项”错误,请参阅此答案。