如何在htaccess中使用301重定向传递查询 [英] How to pass query with 301 redirect in htaccess

查看:87
本文介绍了如何在htaccess中使用301重定向传递查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码进一步向下重定向到URL

 / list-of-bar-skills-in-foo 

这很好但是,我不能

 $ _ GET 

变量industry和q了。有什么想法我错过了什么?谢谢。



我的尝试:



 RewriteEngine On 
RewriteBase /
#redirect /skills/keywords/list.php?industry=foo&q=bar
#to / list-of-bar-skills-in-foo
RewriteCond%{THE_REQUEST} /skills/keywords/list\.php\?industry=([^&]*)&q=([^\s]+)[NC]
RewriteRule ^ skills / keywords / list\.php $ / list-of-%2-skills-in-%1? [L,R = 301]
#rewrite旧URL的新URL
RewriteRule ^ list-of - ([^ - ] +) - skill-in - ([^ - ] +)/? $ /skills/keywords/list.php?industry=$1&q=$2 [NC,L]

解决方案

_GET

变量industry和q了。有什么想法我错过了什么?谢谢。



我的尝试:



 RewriteEngine On 
RewriteBase /
#redirect /skills/keywords/list.php?industry=foo&q=bar
#to / list-of-bar-skills-in-foo
RewriteCond%{THE_REQUEST} /skills/keywords/list\.php\?industry=([^&]*)&q=([^\s]+)[NC]
RewriteRule ^ skills / keywords / list\.php


/ list-of-%2-skills-in-%1? [L,R = 301]
#rewrite旧URL的新URL
RewriteRule ^ list-of - ([^ - ] +) - skill-in - ([^ - ] +)/?

/skills/keywords/list.php?industry =

The code further down redirect to the URL

/list-of-bar-skills-in-foo

which is fine however, I can't

$_GET

the variables "industry" and "q" anymore. Any ideas what am I missing? Thanks.

What I have tried:

RewriteEngine On
RewriteBase /
#redirect /skills/keywords/list.php?industry=foo&q=bar
#to /list-of-bar-skills-in-foo
RewriteCond %{THE_REQUEST} /skills/keywords/list\.php\?industry=([^&]*)&q=([^\s]+) [NC]
RewriteRule ^skills/keywords/list\.php$ /list-of-%2-skills-in-%1? [L,R=301]
#rewrite new URL to the old one
RewriteRule ^list-of-([^-]+)-skills-in-([^-]+)/?$ /skills/keywords/list.php?industry=$1&q=$2 [NC,L]

解决方案

_GET

the variables "industry" and "q" anymore. Any ideas what am I missing? Thanks.

What I have tried:

RewriteEngine On
RewriteBase /
#redirect /skills/keywords/list.php?industry=foo&q=bar
#to /list-of-bar-skills-in-foo
RewriteCond %{THE_REQUEST} /skills/keywords/list\.php\?industry=([^&]*)&q=([^\s]+) [NC]
RewriteRule ^skills/keywords/list\.php


/list-of-%2-skills-in-%1? [L,R=301] #rewrite new URL to the old one RewriteRule ^list-of-([^-]+)-skills-in-([^-]+)/?


/skills/keywords/list.php?industry=


这篇关于如何在htaccess中使用301重定向传递查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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