【发布时间】:2013-02-01 06:52:12
【问题描述】:
localhost/mysite/public - 工作 localhost/mysite/public/index.php/tasks - 工作 localhost/mysite/public/tasks - 不工作错误 404
我几乎尝试了所有方法,但仍然有问题。 我有 mod rewrite on - 我用过:sudo a2enmod vhost_alias rewrite 并重新启动服务器
我的 .htaccess 文件:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
我的 etc/apache2/sites-avaliable/default 类似:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
当我将 AllowOverride 更改为 All 时 - 只有“localhost/”在工作,但我无法运行任何网站,例如“localhost/mysite”。
我尝试在默认文件中添加下一个虚拟主机,例如:
<VirtualHost *:80>
DocumentRoot /var/www/mysite/public/
<Directory /var/www/mysite/public/>
AllowOverride All
</Directory>
</VirtualHost>
但它根本不起作用。
【问题讨论】:
-
delmadord 的这个回答救了我的命! stackoverflow.com/a/24785009/1419350
标签: mod-rewrite apache2 laravel laravel-4