使用“从”;php-$u GET[]”;及;“重写规则”;在;htaccess“;至于;d、 com“;及;d、 com/p/1“;
模式1:使用“从”;php-$u GET[]”;及;“重写规则”;在;htaccess“;至于;d、 com“;及;d、 com/p/1“;,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,模式1: URL:domain.com/?sv=g .htaccess:重写规则^page/([0-9]+)/$fa/?page=$1 当我使用from$\u GET['sv']返回给我g 模式2: URL:domain.com/page/1/?sv=g .htaccess:重写规则^page/([0-9]+)/$fa/?page=$1 当我使用from$\u GET['sv']返回给我null 您需要将该标志添加到重写规则中,否则它不会从请求中添加任何现有的查询字符串参数: 当替换URI包含
URL:
domain.com/?sv=g
.htaccess:
重写规则^page/([0-9]+)/$fa/?page=$1
当我使用from
$\u GET['sv']
返回给我g
模式2:
URL:
domain.com/page/1/?sv=g
.htaccess:
重写规则^page/([0-9]+)/$fa/?page=$1
当我使用from
$\u GET['sv']
返回给我null
您需要将该标志添加到重写规则中,否则它不会从请求中添加任何现有的查询字符串参数: 当替换URI包含查询字符串时,RewriteRule的默认行为是丢弃现有查询字符串,并用新生成的查询字符串替换它。使用[QSA]标志会导致组合查询字符串 试试这个:
RewriteRule ^page/([0-9]+)/$ fa/?page=$1 [QSA]
.htaccess:
RewriteEngine On
RewriteRule ^page/([0-9]+)/$ fa/?page=$1 [QSA]
RewriteRule ^page/([0-9]+)$ fa/?page=$1 [QSA]
请阅读以下内容:
非常感谢