问题
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