Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-28-2012, 10:44 AM   #1
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
Easy WordPress Automated Subdomain (for developers only)

Thought I would make a post for all you developers out there.

I try and avoid WordPress Multisite/Network when I can.

But I often find I have to setup many sites for testing.

I thought I would share a quick and easy way to do this via .htaccess and apache 1.3 or 2.x

First your apache entry for httpd.conf

192.168.1.180 is the domains ip address for this example, and mydomain.com is the domain you are setting this method up for.

Remember you need to add a *.mydomain.com entry either into your dns, or via your dns control panel with your host.

Code:
<VirtualHost 192.168.1.180>
ServerName mydomain.com
ServerAlias www.mydomain.com *.mydomain.com
DocumentRoot /home/chris/public_html
<Directory "">
Options ALL -Indexes
AllowOverride ALL
</Directory>

LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
ErrorLog /home/chris/public_html/logs/error.log
CustomLog /home/chris/public_html/logs/access.log common
CustomLog /home/chris/public_html/logs/referer.log referer

</VirtualHost>
Now for the htaccess bit.

You will want to make a subdirectory in your mydomain.com directory called subs

here is the apache entry for 2.x

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+)\.mydomain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subs/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ http://%2.mydomain.com%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} ^.*\.([^\.]+\.mydomain\.com)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.mydomain\.com$ [NC]
RewriteCond %1:::%{REQUEST_URI} !^(.+):::/subs/\1(/.*)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subs/%1/ -d
RewriteRule ^(.*)$ /subs/%1/$1 [QSA,L]
this will map subdomain.mydomain.com to the /subs directory

so create a subdirectory in /subs say for links, which would be mapped to links.mydomain.com

so now links.mydomain.com will serve files in /subs/links.

For those running apache 1.3 here is the correct htaccess

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+)\.mydomain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subs/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ http://%2.mydomain.com%{REQUEST_URI}/ [R=301,L]
RewriteCond %{HTTP_HOST} ^.*\.([^\.]+\.mydomain\.com)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.)?mydomain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.mydomain\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subs/%1/ -d
RewriteRule ^(.*)$ /subs/%1%{REQUEST_URI} [QSA,L]
so now you can create subdirectories, say files, links, hello, etc and those will all be sub domains on mydomain.com

I find this easier for me to develop without adding entries each time to my server config.

__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-28-2012, 02:26 PM   #2
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,359
bump for developers ;)
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


WP Stuff
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-28-2012, 02:28 PM   #3
papill0n
Unregistered Abuser
 
Industry Role:
Join Date: Oct 2007
Posts: 15,547
you shall be rewarded with pussy lips
papill0n is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-28-2012, 02:30 PM   #4
papill0n
Unregistered Abuser
 
Industry Role:
Join Date: Oct 2007
Posts: 15,547
papill0n is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-28-2012, 03:18 PM   #5
Markul
Likes Pie
 
Markul's Avatar
 
Industry Role:
Join Date: Dec 2007
Location: The land that liberated porn
Posts: 12,401
Thanks dude passed it on to my techie, said it was useful
Markul is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-28-2012, 03:22 PM   #6
Horny Dude
Earn enough to buy coffee
 
Horny Dude's Avatar
 
Industry Role:
Join Date: May 2002
Location: San Diego, Ca.
Posts: 4,912
How come u don't like Wordpress MS? I love to use it for building and testing. Thanks for the tip.
__________________
Horny Dude is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-28-2012, 03:22 PM   #7
2012
So Fucking What
 
2012's Avatar
 
Industry Role:
Join Date: Jul 2006
Posts: 17,189

very nice,thank you so much for your time and effort
__________________
best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself
2012 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.