删除public / from url我搜索并尝试按照这些步骤
将server.php更改为index.php
我尝试添加
RewriteEngine On RewriteRule ^(。*)$ public / $ 1 [L]
到我的/.htaccess删除url public它没有用。
但是如果我删除该行就行了但是我的所有Url链接到css它是错误的路径
NOTE :: I PUT all my Css into public/assets if I move folder assets to my / It work but is their anyway If I dont want to move my floder assets
更新.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
# 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 :(得分:0)
您可以通过2种可能的方式做到这一点:
(1)将Laravel根文件夹中的server.php重命名为index.php 将.htaccess文件从/ public目录复制到Laravel根文件夹。对于静态文件,您可以更改htaccess文件
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]
(2)无需对htaccess进行任何操作。
1) copy index.php in public folder. remove/rename index.php in public.
2) paste in root folder of the project
3) Now open index.php and change 2 url paths like below.
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
仅此而已:)
通过这种方式,您需要通过在这些路径中添加/ public /来更改js和css文件的路径。