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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/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
.htaccess 是否将dir/page/page重定向设置为与dir/page不同?_.htaccess_Url_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess 是否将dir/page/page重定向设置为与dir/page不同?

.htaccess 是否将dir/page/page重定向设置为与dir/page不同?,.htaccess,url,mod-rewrite,url-rewriting,.htaccess,Url,Mod Rewrite,Url Rewriting,我有一些.htaccess重写规则,如下所示: RewriteRule name/john item.php?id=1 [NC,L,QSA] RewriteRule name/jill item.php?id=2 [NC,L,QSA] 在上面的页面上,我想链接到类似于name/john/profile的内容。我尝试了以下规则: RewriteRule name/john/profile profile.php?id=1 [NC,L,QSA] RewriteRule name/jill/prof

我有一些
.htaccess
重写规则,如下所示:

RewriteRule name/john item.php?id=1 [NC,L,QSA]
RewriteRule name/jill item.php?id=2 [NC,L,QSA]
在上面的页面上,我想链接到类似于
name/john/profile
的内容。我尝试了以下规则:

RewriteRule name/john/profile profile.php?id=1 [NC,L,QSA]
RewriteRule name/jill/profile profile.php?id=2 [NC,L,QSA]
但是单击这些链接会重定向到
item.php
,而不是
profile.php

是否无法使用更深层的规则,或者我是否缺少一个标志?

您可以使用:

RewriteRule ^name/john/?$ item.php?id=1 [NC,L,QSA]
RewriteRule ^name/jill/?$ item.php?id=2 [NC,L,QSA]
RewriteRule ^name/john/profile/?$ profile.php?id=1 [NC,L,QSA]
RewriteRule ^name/jill/profile/?$ profile.php?id=2 [NC,L,QSA]
我喜欢添加
/?
,因为在这之后可以使用final
/