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
.htaccess htaccess将文件夹与别名合并_.htaccess - Fatal编程技术网

.htaccess htaccess将文件夹与别名合并

.htaccess htaccess将文件夹与别名合并,.htaccess,.htaccess,我有3个文件夹在我的根目录的子目录,我想合并 我的网站地图: mywebsite.com mywebsite.com/test/ mywebsite.com/test/one/ mywebsite.com/test/one/one.php mywebsite.com/test/two/two.php mywebsite.com/test/three/three.php 我想访问: mywebsite.com/test/one/one.php mywebsite.com/test/two/two

我有3个文件夹在我的根目录的子目录,我想合并

我的网站地图:

mywebsite.com
mywebsite.com/test/
mywebsite.com/test/one/
mywebsite.com/test/one/one.php
mywebsite.com/test/two/two.php
mywebsite.com/test/three/three.php
我想访问:

mywebsite.com/test/one/one.php
mywebsite.com/test/two/two.php
mywebsite.com/test/three/three.php
通过使用:

mywebsite.com/test/combine/one.php
mywebsite.com/test/combine/two.php
mywebsite.com/test/combine/three.php

解决方案 这是可行的,但我想尽量减少脚本


如果您简化了它,可以用这种方式进行整合

RewriteEngine On

RewriteCond %{REQUEST_FILENAME}  -f [OR] 
RewriteCond %{REQUEST_FILENAME}  -d
RewriteRule ^ - [L]

RewriteCond %{DOCUMENT_ROOT}/test/$1/$1.php -f 
RewriteRule ^combine/(.*)(?:\.php)$  /test/$1/$1.php  [L]

我尝试过这样做,但没有效果,我认为问题在于cond%1是的,对不起,我没有想到您不能在
测试字符串中使用regex。然而,你不能简化它吗?您似乎只在查找php文件,所以请尝试我的更新。我没有.htaccess文件。你是说密码?这对我来说很好。顺便说一句,你是否在URL中包含
测试
?不,我没有包含测试,我在使用你的代码时遇到服务器配置错误。哎呀,有一个输入错误。在规则的第一部分。我修好了。
RewriteEngine On

RewriteCond %{REQUEST_FILENAME}  -f [OR] 
RewriteCond %{REQUEST_FILENAME}  -d
RewriteRule ^ - [L]

RewriteCond %{DOCUMENT_ROOT}/test/$1/$1.php -f 
RewriteRule ^combine/(.*)(?:\.php)$  /test/$1/$1.php  [L]