[英]Laravel Url Rewrite and avoid the public folder
I've added the following to my public/.htaccess file in my laravel project. 我已将以下内容添加到我的laravel项目中的public / .htaccess文件中。
#### Force lower case URL ####
RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].*
RewriteRule ^ ${lc:%{REQUEST_URI}} [L,R=301]
It works as far as converting all upper-case characters to lower, however it reroutes the url to the public folder. 它的工作原理是将所有大写字符转换为较低的字符,但是它会将URL重新路由到公用文件夹。
ie. 即。 /jobs gets rerouted to /public/jobs
/ jobs被重新路由到/ public / jobs
Is there away to avoid this? 有没有避免这种情况?
You shouldn't edit or add .htaccess
file, edit index.php
etc. What you should do is point web server to a public
directory instead of root one . 您不应该编辑或添加
.htaccess
文件,编辑index.php
等。您应该做的是将Web服务器指向public
目录而不是根目录 。
If you're using Apache, edit these lines in a virtual host block: 如果您正在使用Apache,请在虚拟主机块中编辑以下行:
DocumentRoot "C:/projects/laravel/public"
<Directory "C:/projects/laravel/public">
Restart Apache and everything will work as expected. 重启Apache,一切都会按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.