Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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中的file1.xml file2.xml_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess htaccess中的file1.xml file2.xml

.htaccess htaccess中的file1.xml file2.xml,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我有一个php网站 我生成的xml文件如下所示: file1.xml file2.xml file3.xml ... myhtaccess RewriteRule ^file\.xml$ file.php [L] 因此,当我键入file.xml时,它会打开file.php 有没有办法做到这一点: file5.xml -> file.php?n=5 我想在filefile7.xml之后获取数字,并将其发送到php,就像file.php?n=7尝试: RewriteRule ^file

我有一个php网站

我生成的xml文件如下所示:

file1.xml
file2.xml
file3.xml
...
myhtaccess

RewriteRule ^file\.xml$ file.php [L] 
因此,当我键入file.xml时,它会打开file.php

有没有办法做到这一点:

file5.xml -> file.php?n=5
我想在file
file7.xml
之后获取数字,并将其发送到php,就像
file.php?n=7
尝试:

RewriteRule ^file([0-9]+)\.xml$ file.php?n=$1 [L] 

这将在内部将/fileNumber.xml重定向到/file.php?n=number

重写规则^file(.*)\.xml$file.php?n=$1[L]如果您还想访问
/file.xml
uri,请将捕获组中的
+
替换为
*