Php 更改重写规则以更改参数结果
以下是我的Apache 2目录配置:Php 更改重写规则以更改参数结果,php,.htaccess,apache2,Php,.htaccess,Apache2,以下是我的Apache 2目录配置: <Directory /var/www/html/website/> Options +SymLinksIfOwnerMatch RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/]+)/([^/]+)/?$
<Directory /var/www/html/website/>
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?operator=$1&url=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ index.php?operator=$1 [L,QSA]
</Directory>
选项+符号链接所有者匹配
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([^/]+)/([^/]+)/?$index.php?运算符=$1和url=$2[L,QSA]
重写规则^([^/]+)/?$index.php?运算符=$1[L,QSA]
如果输入,则会看到:?operator=a&url=b
。这很好,也是我所期望的。如果输入,则会看到:
?operator=a&url=
。这也是可以预料的
我的问题是我工作的结果。我看到的是?operator=index.php&url=
我希望看到这两个参数都为空,但运算符中填充了'index.php'
我如何更改我的“RewriteRule”,使参数都为空,而网站后面没有目录,如我的示例所示?这是因为RewriteRule运行了两次,因为
RewriteCond
应用于下一个立即RewriteRule
将规则更改为:
<Directory /var/www/html/website/>
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?operator=$1&url=$2 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?operator=$1 [L,QSA]
</Directory>
选项+符号链接所有者匹配
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([^/]+)/([^/]+)/?$index.php?运算符=$1和url=$2[L,QSA]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^([^/]+)/?$index.php?运算符=$1[L,QSA]