Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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
Mod rewrite 将规则Q,example.com/xml/title/重写为example.com/xml/index.php?var=title_Mod Rewrite - Fatal编程技术网

Mod rewrite 将规则Q,example.com/xml/title/重写为example.com/xml/index.php?var=title

Mod rewrite 将规则Q,example.com/xml/title/重写为example.com/xml/index.php?var=title,mod-rewrite,Mod Rewrite,我有example.com/xml/index.php,我想通过这个url example.com/xml/title/访问它,最后一部分是index.php的GET var,它应该显示使用该var的结果,我应该在.htaccess文件中添加什么代码? 谢谢在文档根目录的.htaccess文件中尝试以下操作: RewriteEngine on RewriteRule ^xml/([^/]+)/$ xml/index.php?var=$1 看起来不错,只是一个小问题,它只适用于最后一个slash

我有example.com/xml/index.php,我想通过这个url example.com/xml/title/访问它,最后一部分是index.php的GET var,它应该显示使用该var的结果,我应该在.htaccess文件中添加什么代码?
谢谢

在文档根目录的.htaccess文件中尝试以下操作:

RewriteEngine on
RewriteRule ^xml/([^/]+)/$ xml/index.php?var=$1

看起来不错,只是一个小问题,它只适用于最后一个slash example.com/xml/title/,但不适用于example.com/xml吗/title@Tom:此规则改为:重写COND$1=index.php重写规则^xml/[^/]+/?$xml/index.php?var=$1