我的laravel项目遇到问题
我要删除网址中的index.php
喜欢
如果使用此按钮,我找不到404
但是如果我使用
http://localhost/react/Lara-react/public/index.php/admin/home
它的工作原理和
^适用于
我的.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
我尝试过
但不起作用...
有人帮助
答案 0 :(得分:1)
http://localhost/react/Lara-react/public/admin/home
不起作用,因为您的根路径为http://localhost,因此url不会搜索index.php。 当您启动命令php artisan serve命令时,应用程序的根目录变为 http://localhost/react/Lara-react/index.php因此,所有路由都将附加到root创建 http://localhost/react/Lara-react/public/index.php/admin/home可使应用正常工作
在生产中,您也将项目的根路径定义为/var/www/html/react/Lara-react/index.php。
因此对于使用php artisan serve命令进行开发,它会在生产过程中创建模拟环境,因此很有帮助
答案 1 :(得分:0)
1)。运行常见的“ gedit /etc/apache2/apache2.conf”
Alias /project_name /var/www/html/project_name/public/
<Directory /var/www/html/project_name/public>
AllowOverride All
Order allow,deny
allow from all
</Directory>
2)。在'project_name / public / .htaccess'中添加基本URL
RewriteBase /project_name
3)。最终运行“ service apache2 reastart”