htaccess的 - 子域中$ _GET参数 [英] htaccess - subdomain as $_GET parameter

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

问题描述

我有以下已经在我的的.htaccess 文件:

  RewriteEngine叙述上

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?路径= $ 1 [L,QSA]
 

不过,我想增加一条规则是这样的:

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

但不绑定到 example.com ,它必须运行在任何领域。

解决方案

  RewriteEngine叙述上
的RewriteCond%{HTTP_HOST}!^(WWW)\。 [NC]
的RewriteCond%{HTTP_HOST} ^(。*)\。(。*)\。com [NC]
(。*)重写规则的http://www.%2.com/名称=%1 [R = 301,L]
 

重写 http://subdomain.domain.com http://www.domain.com/?name=subdomain

将二者结合起来尝试这样的事情

  RewriteEngine叙述上
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{HTTP_HOST}!^(WWW)\。 [NC]
的RewriteCond%{HTTP_HOST} ^(。*)\。(。*)\。com [NC]
(。*)重写规则的http://www.%2.com/index.php路线= 1 $&安培;名称=%1 [R = 301,L]
 

这将重定向 http://subdomain.domain.com/hello-world http://www.domain.com/index ?.PHP路线=你好世界和放大器;名称=子域名

I have the following already in my .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

But I want to add a rule like this:

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

But without it binding to example.com and it must work on any domain.

解决方案

RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.com [NC]
RewriteRule (.*) http://www.%2.com/?name=%1 [R=301,L]

rewrites http://subdomain.domain.com to http://www.domain.com/?name=subdomain

to combine the two try something like this

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^(www)\. [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.com [NC]
RewriteRule (.*) http://www.%2.com/index.php?route=$1&name=%1 [R=301,L]

that will redirect http://subdomain.domain.com/hello-world to http://www.domain.com/index.php?route=hello-world&name=subdomain

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

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