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

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 使用htaccess的URL屏蔽_.htaccess_Url_Masking - Fatal编程技术网

.htaccess 使用htaccess的URL屏蔽

.htaccess 使用htaccess的URL屏蔽,.htaccess,url,masking,.htaccess,Url,Masking,我在下面有一个url: 如果PropertyBuyRent=rent且所有其他变量均为空,则url应如下所示: 如何为此写入htaccess?您可以使用此规则: RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(testing/mypage\.php)\?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&

我在下面有一个url:

  • 如果PropertyBuyRent=rent且所有其他变量均为空,则url应如下所示:
  • 如何为此写入htaccess?

    您可以使用此规则:

    RewriteEngine On
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(testing/mypage\.php)\?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [NC]
    RewriteRule ^ /%1/TimeshareForRent/All? [R=301,L]
    
    RewriteRule ^(testing/mypage.php)/TimeshareForRent/All/?$ /$1?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [L,NC,QSA]
    

    参考:您可以使用这一行并在php文件中进行如下编辑

    RewriteRule ^mypage.php/TimeshareForRent/All/?$ mypage.php?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price= [L,NC,QSA]
    

    当您的条件匹配时,您可以告诉您的php文件重定向到“mypage.php/TimeshareForRent/All”,因为根据上述规则,它将用不带变量的url屏蔽变量的url,就像这样,您正在以
    http://www.mysite.com/mypage.php?PropertyBuyRent=rent&Developer=&Resort=&City=&State=&Country=&Price=
    ?是的,它应该更改为该url并打开mypage.php/TimeshareForRent/All/,但在其后面传递变量,实际上,用mypage.php/TimeshareForRent/All/oh屏蔽变量不再给出错误,但当我打开此链接时:。。。它不会更改为另一个urlno,它位于一个名为testing的文件夹中,您可以在该文件夹中执行某些操作吗?