laravel apache 无法读取干净 url 的 htaccess?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11267967/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
htaccess for clean urls not being read by apache?
提问by Boyd
I'm getting kinda crazy over here because I already wasted two hours getting my clean URLs enabled for the laravel framework.
我在这里有点疯狂,因为我已经浪费了两个小时来为 laravel 框架启用干净的 URL。
I'm on a Mac and have a XAMPP setup. The Loadmodule mod_rewrite is commented out and php_info() says mod_rewrite module is loaded.
我在 Mac 上并且有一个 XAMPP 设置。Loadmodule mod_rewrite 被注释掉,php_info() 表示 mod_rewrite 模块已加载。
My .htaccess file in the public folder of the laravel framework contains the code for cleans URLs (as stated on their website) but still, when I surf domain.com/account it gives me a 404.
我在 laravel 框架的公共文件夹中的 .htaccess 文件包含清理 URL 的代码(如他们的网站上所述)但是,当我浏览 domain.com/account 时,它给了我 404。
The laravel framework folder runs as a virtual host.
laravel 框架文件夹作为虚拟主机运行。
What could it be, that is going wrong?!
怎么回事,哪里出错了?!
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
回答by Concordus Applications
Make sure Loadmodule mod_rewrite
is uncommented.
确保Loadmodule mod_rewrite
未注释。
Make sure you have AllowOverride set appropriately for the vhost to allow .htaccess to do its thing.
确保为 vhost 适当设置了 AllowOverride 以允许 .htaccess 做它的事情。
One example of a good directive is:
一个好的指令的例子是:
<Directory "/some/absolute/path/htdocs">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
A good patter to follow for .htaccess for what you are trying to do is:
.htaccess 的一个很好的模式是:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/ [L]
</IfModule>
Very close to what you are doing.
非常接近你正在做的事情。
Restart your apache server.
重新启动您的 apache 服务器。