简体   繁体   English

使用htaccess删除框架的目录URL

[英]remove directory url for framework with htaccess

i have this code .htaccess work for laravel framework 我有此代码.htaccess为laravel框架工作

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /testing/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [NC,L]
</IfModule>  

which work fine but the problem in framework i go to site example.com/testing 哪个工作正常,但框架中的问题我去了example.com/testing网站

the problem laravel framework read /testing as route 问题laravel框架读/测试为路线

so i have put all route under testing 所以我已经测试了所有路线

so the Question is :how can i make apache send PHP route without "/testing" ? 所以问题是:如何使apache在不进行“ / testing”的情况下发送PHP路由?

Simply excluding from the scope all requests that match /testing path. 只需从范围中排除所有与/ testing路径匹配的请求即可。 View htaccess docs 查看htaccess文档

RewriteEngine On
RewriteBase /testing/public/
RewriteCond %{REQUEST_URI} !^/testing$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [NC,L]

But anyway you should not do this , you are redirecting your incoming requests to /testing/public/index.php . 但是无论如何,您都不应该这样做 ,您会将传入的请求重定向到/testing/public/index.php

You have to configure the virtualhost pointing directly to /public folder in your laravel application as described in http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost 您必须按照http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost中的说明配置直接指向laravel应用程序中/public文件夹的虚拟主机

And this is why you should do : https://security.stackexchange.com/questions/56736/is-web-app-safe-in-not-public-folder 这就是为什么您应该这样做https : //security.stackexchange.com/questions/56736/is-web-app-safe-in-not-public-folder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM