的.htaccess RewiteCond(QUERY

编程入门 行业动态 更新时间:2024-10-18 18:19:06
本文介绍了的.htaccess RewiteCond(QUERY_STRING)与2变量并重写正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要从重写我的网址:

  

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

  

HTTP://***/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:

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

to:

***/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

本文发布于:2023-11-01 12:52:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549386.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:htaccess   RewiteCond   QUERY

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!