[英]Hide folder path from url htaccess
I want to hide the folder path from the URL but still get the content as the folder was in the path, example: 我想从URL隐藏文件夹路径,但是仍然获得内容,因为文件夹位于路径中,例如:
Today I have: www.mywebsite.com/v2/test.php I want the use to see: www.mywebsite.com/test.php 今天我有:www.mywebsite.com/v2/test.php我想用看:www.mywebsite.com/test.php
But, i do have those 2 test.php file, one in the root, and another one inside the /v2/ folder, i want the user to see the one inside the /v2/ folder. 但是,我确实有那两个test.php文件,一个在根目录中,另一个在/ v2 /文件夹中,我希望用户看到在/ v2 /文件夹中的一个。
Tried this one: Hiding folder in URL using .htaccess 尝试过以下方法: 使用.htaccess在URL中隐藏文件夹
But at the end user sees the test.php in the root folder, what i don't want. 但是最终用户在根文件夹中看到了test.php,这是我不想要的。
You can use this rule in your site root .htaccess: 您可以在网站根目录.htaccess中使用此规则:
RewriteEngine on
RewriteRule !^v2/ v2%{REQUEST_URI} [NC,L]
!^v2/
is negative condition that returns true if URI doesn't start with /v2/
!^v2/
是否定条件,如果URI不以/v2/
开头,则返回true v2%{REQUEST_URI}
forwards all the URIs to /v2/
path. v2%{REQUEST_URI}
将所有URI转发到/v2/
路径。 This means even www.domain.com
will be forwarded to www.domain.com/v2/
www.domain.com
也将转发到www.domain.com/v2/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.