Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache url重写到虚拟路径始终保持虚拟路径_Apache_.htaccess_Redirect_Mod Rewrite_Conditional Statements - Fatal编程技术网

Apache url重写到虚拟路径始终保持虚拟路径

Apache url重写到虚拟路径始终保持虚拟路径,apache,.htaccess,redirect,mod-rewrite,conditional-statements,Apache,.htaccess,Redirect,Mod Rewrite,Conditional Statements,我有一个物理文件夹: http://www.myowndomain.com/path1/ 我希望所有的请求都是http://www.myowndomain.com/path1/*和http://www.myowndomain.com/path2/*(这是一个虚拟文件夹,它不存在)将被重定向到http://www.myowndomain.com/path1/*。此外,我希望所有这些请求都显示在url栏中 http://www.myowndomain.com/path2/* 我应该把.htacc

我有一个物理文件夹:

http://www.myowndomain.com/path1/
我希望所有的请求都是
http://www.myowndomain.com/path1/*
http://www.myowndomain.com/path2/*
(这是一个虚拟文件夹,它不存在)将被重定向到
http://www.myowndomain.com/path1/*
。此外,我希望所有这些请求都显示在url栏中

http://www.myowndomain.com/path2/*

我应该把
.htaccess
文件放在哪里,它的内容是什么?

将以下规则添加到/root.htaccess中

RewriteEngine on

#1)externally Redirect /path1/* => /path2/*##
RewriteCond %{THE_REQUEST} /path1/(.*)\sHTTP [NC]
RewriteRule ^ /path2/%1 [NE,L,R]
#2)internally Redirect /path2/* => /path1/*##
RewriteRule ^/?path2/(.*)$ /path1/$1 [NC,L]
这将在内部将/path2/重定向到/path1

不起作用。在地址栏中显示,而不是按要求显示。在地址栏中显示,而不是按要求显示