htaccess的子域redirct与去年URL参数 [英] htaccess subdomain redirct with last url parameter

查看:435
本文介绍了htaccess的子域redirct与去年URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个.htaccess文件重定向我的子域名和网址的最后一个变量到新的位置。这是我想要做的:

I want to write a .htaccess file for redirecting my subdomains and URL's last variable to a new location. Here is what I want to do:

HTTP(S)://abc.example.com/books

http(s)://abc.example.com/books

我希望我的内部URL是这样的:

I want my internal URL to be like:

http://example.com/?name=abc&type=books

我已经得到的子域名重定向到工作,但我不能做子站点变量URL的最后一部分。

I have already gotten the subdomain redirect to work but I am not able to do subdomain with variable in last part of URL.

我怎样才能做到这一点?

How can I accomplish this?

推荐答案

这应该做你想要的:

RewriteCond %{HTTP_HOST} ^(.+).example.com
RewriteRule ^(.*)% http://example.com/?name=%1&type=$1 [R,L]

在%1是指使用第一个捕获组从上面的RewriteCond。

The "%1" means use the first capture group from the RewriteCond above.

这篇关于htaccess的子域redirct与去年URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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