subdomain

PHP Getting Domain Name From Subdomain

有些话、适合烂在心里 提交于 2019-11-26 03:58:31
问题 I need to write a function to parse variables which contain domain names. It\'s best I explain this with an example, the variable could contain any of these things: here.example.com example.com example.org here.example.org But when passed through my function all of these must return either example.com or example.co.uk, the root domain name basically. I\'m sure I\'ve done this before but I\'ve been searching Google for about 20 minutes and can\'t find anything. Any help would be appreciated.

Can (domain name) subdomains have an underscore “_” in it?

泪湿孤枕 提交于 2019-11-26 01:44:23
问题 Can subdomains (domain names) have underscore _ in them? 回答1: Most answers given here are false . It is perfectly legal to have an underscore in a domain name. Let me quote the standard, RFC 2181, section 11, "Name syntax": The DNS itself places only one restriction on the particular labels that can be used to identify resource records. That one restriction relates to the length of the label and the full name. [...] Implementations of the DNS protocols must not place any restrictions on the

.htaccess rewrite subdomain to directory

我只是一个虾纸丫 提交于 2019-11-26 01:27:39
问题 Is it possible to use .htaccess to rewrite a sub domain to a directory? Example: http://sub.domain.com/ shows the content of http://domain.com/subdomains/sub/ 回答1: Try putting this in your .htaccess file: RewriteEngine on RewriteCond %{HTTP_HOST} ^sub.domain.com RewriteRule ^(.*)$ /subdomains/sub/$1 [L,NC,QSA] For a more general rule (that works with any subdomain, not just sub ) replace the last two lines with this: RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com RewriteRule ^(.

PHP function to get the subdomain of a URL

只谈情不闲聊 提交于 2019-11-26 01:21:21
Is there a function in PHP to get the name of the subdomain? In the following example I would like to get the "en" part of the URL: en.example.com Michael Deal Here's a one line solution: array_shift((explode('.', $_SERVER['HTTP_HOST']))); Or using your example: array_shift((explode('.', 'en.example.com'))); EDIT: Fixed "only variables should be passed by reference" by adding double parenthesis. EDIT 2 : Starting from PHP 5.4 you can simply do: explode('.', 'en.example.com')[0]; Uses the parse_url function. $url = 'http://en.example.com'; $parsedUrl = parse_url($url); $host = explode('.',

use localStorage across subdomains

爷,独闯天下 提交于 2019-11-26 00:54:30
问题 I\'m replacing cookies with localStorage on browsers that can support it (anyone but IE). The problem is site.com and www . site.com store their own separate localStorage objects. I believe www is considered a subdomain (a stupid decision if you ask me). If a user was originally on site.com and decides to type in www . site.com on her next visit, all her personal data will be inaccessible. How do I get all my \"subdomains\" to share the same localStorage as the main domain? 回答1: This is how I

Get the subdomain from a URL

心不动则不痛 提交于 2019-11-26 00:47:12
问题 Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the first period then return whatever came after the \"http://\" ... Then you remember http://super.duper.domain.example Oh. So then you think, okay, find the last period, go back a word and get everything before! Then you remember http://super.duper.domain.co.uk And you\'re back to square one. Anyone have any great ideas besides storing a list of all TLDs? 回答1: Anyone have any great ideas besides

How to let PHP to create subdomain automatically for each user?

核能气质少年 提交于 2019-11-26 00:18:44
问题 How do I create subdomain like http://user.mywebsite.com ? Do i have to access htaccess somehow? Is it actually simply possible to create it via pure php code or I need to use some external script-server side language? To those who answered: Well, then, should i ask my hosting if they provide some sort of DNS access?? 回答1: You're looking to create a custom A record . I'm pretty sure that you can use wildcards when specifying A records which would let you do something like this: *.mywebsite

Create subdomains on the fly with .htaccess (PHP)

依然范特西╮ 提交于 2019-11-25 22:27:20
问题 I am looking to create a system which on signup will create a subdomain on my website for the users account area. e.g. johndoe.website.com I think it would be something to do with the .htaccess file and possibly redirecting to another location on the website? I don\'t actually know. But any information to start me off would be greatly appreciated. Creating a sign up area is not the problem - I have done this many a time. I am just unsure where to start with the subdomain. 回答1: The quick

Can (domain name) subdomains have an underscore “_” in it?

和自甴很熟 提交于 2019-11-25 20:32:27
Can subdomains (domain names) have underscore _ in them? bortzmeyer Most answers given here are false . It is perfectly legal to have an underscore in a domain name. Let me quote the standard, RFC 2181, section 11, "Name syntax" : The DNS itself places only one restriction on the particular labels that can be used to identify resource records. That one restriction relates to the length of the label and the full name. [...] Implementations of the DNS protocols must not place any restrictions on the labels that can be used. In particular, DNS servers must not refuse to serve a zone because it

use localStorage across subdomains

荒凉一梦 提交于 2019-11-25 19:15:50
I'm replacing cookies with localStorage on browsers that can support it (anyone but IE). The problem is site.com and www . site.com store their own separate localStorage objects. I believe www is considered a subdomain (a stupid decision if you ask me). If a user was originally on site.com and decides to type in www . site.com on her next visit, all her personal data will be inaccessible. How do I get all my "subdomains" to share the same localStorage as the main domain? This is how I use it across domains... Use an iframe from your parent domain - say parent.com Then on each child.com domain,