TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Domain mapping (http://www.talkphp.com/general/3981-domain-mapping.html)

Jmz 02-17-2009 10:30 AM

Domain mapping
 
Does anybody know how sites like wordpress.org let users add their own domains to their blogs.

So for example I could add my domain myblog.com and it would point to myblog.wordpress.org.

I'm not even sure it's done with PHP *!* but if somebody could point me in the right direction it would be great :-D

buildakicker 02-18-2009 12:35 AM

Use mod_rewrite. You can easily create subdirectories with php.

I found this, please post what you come up with!

Jmz 02-18-2009 09:25 AM

Creating the subdomain isn't my problem, I have that working already.

I want users to have the option to use a top level domain if they want.

Scottymeuk 02-18-2009 02:42 PM

Then you are going to start getting into DNS setting etc. You best bet is just to have an external url box and if thats set and valid then redirect to that. But if you want them to have it hosted on yours still then your going to have to be able to change DNS settings etc. Like putting the subdomain into there cname setting etc. Going to be quite hard to do.

Jmz 02-18-2009 04:06 PM

Really at the minute I just want to get a basic idea of how it would work. Then I can have a look at it once the rest of my site is finished.

Even if I end up paying someone else to do it I dont mind. I just want to get a vague idea of what is involved for it to be done.

trmbne2000 02-21-2009 08:37 PM

All of their subdomains like username.wordpress.com are probably handled with wildcard dns (http://en.wikipedia.org/wiki/Wildcard_DNS_record). As far as being able to get www.username.com to map to your wordpress site, I don't know exactly what they do, but this solution may work as a workaround:

Use mod_rewrite to serve master.php in place of all html files, something like this:
Code:

RewriteEngine on
# Skip www.yourdomain.com
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule \.(css|jpe?g|gif|png)$ - [L]
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^www.([\w\.-]+\.[\w]{2,3})/(.*) master.php?domain=$1&args=$2

Then in master.php you would need to have some code to pull out the domain and other arguments passed in the rewritten url.

Hope that gets you started in the right direction.


All times are GMT. The time now is 02:39 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0