Mod rewrite 将规则Q,example.com/xml/title/重写为example.com/xml/index.php?var=title
我有example.com/xml/index.php,我想通过这个url example.com/xml/title/访问它,最后一部分是index.php的GET var,它应该显示使用该var的结果,我应该在.htaccess文件中添加什么代码?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
谢谢在文档根目录的.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