URL重写的子域

编程入门 行业动态 更新时间:2024-10-28 21:30:12
本文介绍了URL重写的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这种情况很简单。我创建了一个通配符子域在我的cPanel的是这样的:* .mysite

The situation is simple. I create a wildcard subdomain in my cpanel that goes something like this: *.mysite.

我可以加载网页,但我想利用通配符的值作为GET因此基于该GET值的页面实际上可以显示相关内容的参数。

I can load the page but I want to take the value of the wildcard as a parameter of GET so the page can actually display the relevant contents based on that GET value.

所以我想知道的是,如果它可能有一个重写规则,可以让我做到以下几点。

So what i want to know is if its possible to have a rewrite rule that allows me to do the following.

获取:$ _ GET ['商店'] =='andystore从URL: HTTP://andystore.mysite。 COM

Get: $_GET['store']=='andystore' from the url: andystore.mysite

推荐答案

您可以在 DOCUMENT_ROOT /的.htaccess 文件中使用此code:

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On RewriteBase / # capture first part of host name RewriteCond %{HTTP_HOST} ^([^.]+)\.mysite\$ [NC] # make sure store= query parameter isn't there RewriteCond %{QUERY_STRING} !(^|&)store= [NC] # rewrite to current URI?store=backererence #1 from host name RewriteRule ^ %{REQUEST_URI}?store=%1 [L,QSA]

更多推荐

URL重写的子域

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

发布评论

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

>www.elefans.com

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