的.htaccess RewiteCond(QUERY_STRING)与2变量并重写正确 [英] .htaccess RewiteCond (QUERY_STRING) with 2 variable and rewrite properly

查看:518
本文介绍了的.htaccess RewiteCond(QUERY_STRING)与2变量并重写正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从重写我的网址:

  

HTTP://***.com/index.php猫= VAR和放大器;页面= 1

  

HTTP://***.com/VAR/1

使用301重定向。

我得到这个至今:

 的RewriteCond%{THE_REQUEST} ^(GET | POST)\的index.php \?
的RewriteCond%{QUERY_STRING} ^猫= \&AMP(*);页=(*)。
重写规则。 / 1%/ 2%[R = 301]

RewriteEngine叙述上

的RewriteCond%{REQUEST_URI} ^ /!(文件|管理员)/
重写规则^(。*)/(。*)$ /index.php?cat=$1&page=$2 [L]
 

但第3的规则似乎并不在所有的工作。 (我在htaccess的初学者)

我该如何解决这个问题?谢谢!

编辑: 由于杰茜,解决方法:

 的RewriteCond%{THE_REQUEST} ^(GET | POST)\的index.php \?
的RewriteCond%{QUERY_STRING} ^猫= \&AMP(*);页=(*)。
重写规则^(。*)/(。*)$ /index.php?cat=$1&page=$2 [L,QSA]

RewriteEngine叙述上

的RewriteCond%{REQUEST_URI} ^ /!(文件|管理员)/
重写规则^(。*)/(。*)$ /index.php?cat=$1&page=$2 [L]
 

解决方案

将其更改为重写规则^()/(的)$ /index.php?cat=$1&page=$2 [L,QSA]和尝试

I need to rewrite my url from:

http://***.com/index.php?cat=VAR&page=1

to:

http://***.com/VAR/1

With 301 redirection.

I got this so far:

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index.php\?
RewriteCond %{QUERY_STRING} ^cat=(.*)\&page=(.*)
RewriteRule . /%1/%2 [R=301]

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(files|admin)/
RewriteRule ^(.*)/(.*)$ /index.php?cat=$1&page=$2 [L]

But the first 3 rules doesn't seems to work at all. (I'm a beginner in htaccess)

How can i fix this problem? Thanks!

EDIT : Thanks to Jassie, the solution:

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /index.php\?
RewriteCond %{QUERY_STRING} ^cat=(.*)\&page=(.*)
RewriteRule ^(.*)/(.*)$ /index.php?cat=$1&page=$2 [L,QSA]

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/(files|admin)/
RewriteRule ^(.*)/(.*)$ /index.php?cat=$1&page=$2 [L]

解决方案

change it to RewriteRule ^(.)/(.)$ /index.php?cat=$1&page=$2 [L,QSA] and try

这篇关于的.htaccess RewiteCond(QUERY_STRING)与2变量并重写正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆