Laravel 4.2重写URL-删除公共 [英] Laravel 4.2 rewrite URL - remove public
问题描述
我的旧域: domain.com
我的laravel项目位于: domain.com/laravel/public 它运作良好,但我不想在URL中看到它.
My laravel project in: domain.com/laravel/public It's working well, but I don't want see public in URL.
我使用以下命令将新的.htaccess文件添加到我的laravel根文件夹( domain.com/laravel/.htaccess )中: RewriteEngine开启
I add new .htaccess file to my root laravel folder (domain.com/laravel/.htaccess) with: RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
当我访问 domain.com/laravel 时,我的jQuery路径为: domain.com/js/jquery.min.js
When I access to domain.com/laravel, my jQuery path is: domain.com/js/jquery.min.js
当我访问 domain.com/laravel/public 时,我的jQuery路径为: domain.com/laravel/public/js/jquery.min.js
When I access to domain.com/laravel/public, my jQuery path is: domain.com/laravel/public/js/jquery.min.js
我不想将公用文件夹中的所有文件都移到根文件夹,因为那里确实有更多文件.
I don't want move all files in public folder to root folder, because really more files there.
最诚挚的问候,
推荐答案
这是我当前的解决方案:
This is my current solution:
<IfModule mod_rewrite.c>
RewriteCond $1 !^(public)
RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>
您必须添加一个重写条件.
You have to add a rewrite condition.
这篇关于Laravel 4.2重写URL-删除公共的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!