Laravel 4.2 rewrite URL - remove public

 ̄綄美尐妖づ 提交于 2020-01-06 13:58:10

问题


My old domain: domain.com

My laravel project in: domain.com/laravel/public It's working well, but I don't want see public in URL.

I add new .htaccess file to my root laravel folder (domain.com/laravel/.htaccess) with: RewriteEngine On

RewriteRule ^(.*)$ public/$1 [L]

When I access to domain.com/laravel, my jQuery path is: domain.com/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.

Best regards,


回答1:


I read more answers in more website, almost their said move all files in public folder to root folder of Laravel application.

It's not good if we have more files there, so, I was try with some way and finally, I just move index.php and .htaccess file to root application.

It's working well, I just change some code when using HTML::script, HTML::css and {{ asset }} As normal, we using HTML::css('style.css'), I just add public before, like this: HTML::css('public/style.css')

I hope it helpful for someone. Best regards.




回答2:


This is my current solution:

<IfModule mod_rewrite.c>
  RewriteCond $1 !^(public)
  RewriteRule ^(.*)$ /public/$1 [L]
</IfModule>

You have to add a rewrite condition.



来源:https://stackoverflow.com/questions/26269780/laravel-4-2-rewrite-url-remove-public

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