xampp apache rewrite not working

匿名 (未验证) 提交于 2019-12-03 03:08:02

问题:

I have a folder called crm in htdocs which contains a fresh laravel 5.1 project and i am trying to acess it via http://localhost/crm/ but it just brings the index of page containing the directory contents instead of the page mapped in my routes.php as

Route::get('/', function () {     return view('panel'); });

i have checked that apache mod_rewrite is enable in httpd.conf

LoadModule rewrite_module modules/mod_rewrite.so  DocumentRoot "C:/xampp/htdocs"       Options Indexes FollowSymLinks Includes ExecCGI      AllowOverride All      Require all granted 

then the .htaccess file in crm/public folder contains

              Options -MultiViews           RewriteEngine On      # Redirect Trailing Slashes...     RewriteRule ^(.*)/$ /$1 [L,R=301]      # Handle Front Controller...     RewriteCond %{REQUEST_FILENAME} !-d     RewriteCond %{REQUEST_FILENAME} !-f     RewriteRule ^ index.php [L] 

I have also tried to change it to

Options +FollowSymLinks RewriteEngine On  RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]

without success.

回答1:

You need to point Laravel to public directory to make it work. For example, if you've installed Laravel in C:/xampp/htdocs/ directory, you need to use these settings:

DocumentRoot "C:/xampp/htdocs/public" 

Do not edit .htacces inside public folder. Try to change settings and load Laravel website by going to localhost first.

When you've edited Apache config file, you should restart web server.



转载请标明出处:xampp apache rewrite not working
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!