本文介绍了重写规则要求的URL与2查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  theyouthtalent.com/user_wall.php?User=khalidmirza&Talent=Business
 

我要重写和重定向像

上述网址

  http://theyouthtalent.com/Business/khalidmirza
 

,其中商务>>人才=商业和khalidmirza >>用户= khalidmirza

现在我使用这些低于mentinoed规则,这是罚款     http://theyouthtalent.com/khalidmirza

但我想用户之前,包括人才(业务)(khalidmirza)

请提出修改下面的规则获得渴望的结果。

  RewriteEngine叙述上

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
?重写规则^(\ w +)$ user_wall.php用户= $ 1安培;人才= $ 2 [L]
的RewriteCond%{} THE_REQUEST user_wall \ .PHP
的RewriteCond%{QUERY_STRING}用户=(\ w +)及人才=(\ w +)
重写规则^ user_wall \ .PHP $ /%1? [R = 301,L]
 

解决方案

您正则表达式来捕获2组件是不正确的重写规则:

  RewriteEngine叙述上

的RewriteCond%{} THE_REQUEST /user_wall\.php [NC]
的RewriteCond%{QUERY_STRING} ^用户=(\ w +)及人才=(\ w +)$ [NC]
重写规则^ user_wall \ .PHP $ / 2%/ 1%? [R = 301,L,NE]

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(\ w +)/(\ w +)/ $ user_wall.php用户= $ 2及?人才= $ 1 [L,QSA]
 
theyouthtalent.com/user_wall.php?User=khalidmirza&Talent=Business

I want to rewrite and redirect above mentioned URL like

http://theyouthtalent.com/Business/khalidmirza

where Business >> Talent=Business and khalidmirza >> User=khalidmirza

right now I am using these below mentinoed rules which are fine for http://theyouthtalent.com/khalidmirza

but I want to include Talent (Business) before User (khalidmirza)

Kindly propose change in below rules to get desire result.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)$ user_wall.php?User=$1&Talent=$2 [L]
RewriteCond %{THE_REQUEST} user_wall\.php
RewriteCond %{QUERY_STRING} User=(\w+)&Talent=(\w+)
RewriteRule ^user_wall\.php$ /%1? [R=301,L]
解决方案

Your regex to capture 2 components isn't correct in the rewrite rule:

RewriteEngine On

RewriteCond %{THE_REQUEST} /user_wall\.php [NC]
RewriteCond %{QUERY_STRING} ^User=(\w+)&Talent=(\w+)$ [NC]
RewriteRule ^user_wall\.php$ /%2/%1? [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(\w+)/(\w+)/?$ user_wall.php?User=$2&Talent=$1 [L,QSA]

这篇关于重写规则要求的URL与2查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 14:02