Catch-all/Wildcard sub-subdomain? .htaccess

Status
Not open for further replies.

Tomcenc

New Member
Messages
57
Reaction score
0
Points
0
I'd like to catch all subdomains of my subdomain and redirect them to a PHP script which will process the subdomain. I need this because I'm creating an online tool for a game which saves it's configuration in a cookie, to allow the user several configurations for the same server they could just use variations of a subdomain, eg:
en10.tomcenc.x10hosting.com
server10.tomcenc.x10hosting.com
qsfd10.tomcenc.x10hosting.com
I know the PHP to parse the server from the subdomain but am unable to catch the subdomains using the code I found on the web (to put in my .htaccess file)

RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST} !^tomcenc\.x10hosting\.com?$
RewriteCond %{HTTP_HOST} ^([^.]+)\.tomcenc\.x10hosting\.com?$
RewriteRule ^$ /server.php [L]

It just gives a "congratulations you installed apache with cpanel" or something like that. For each sub subdomain.

I'll be moving to paid hosting with a real domain before I make it public but I can't get paypal to work (yet). But I suppose I can edit the code myself to work for a subdomain instead of a sub-subdomain.
I'd like the code to get to the right file and query string so it works the same as a real subdomain.
 
Last edited:

Tomcenc

New Member
Messages
57
Reaction score
0
Points
0
You can't unless the subdomain actually exists. If the subdomain doesn't exist you just get a server not found error. You need to either create a subdomain through Cpanel, or use a .htaccess to manage those requests. Since I want a catch-all, I have to use a .htaccess file to process those requests. You can't write PHP code if the PHP is never executed. That's what I'm asking, how do I use a .htaccess file to catch each requested subdomain and pretend as if it existed?
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
You don't. Catch-all is a DNS thing, not a htaccess thing. You have to have catch-all dns set up for you, and THEN you can use whatever you like (Be it php or perl)
 

Tomcenc

New Member
Messages
57
Reaction score
0
Points
0
I don't know if you're right but many tutorials in google talk about mod_rewrite. I just don't manage to get any to work since I don't know anything about the coding used in a .htaccess file.
 
Last edited:

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
You do mod_rewrite or whatever AFTER you get your wildcard DNS setup. I lean strongly towards PHP as it'll make my app more cross compatible for those who aren't running on apache.
 

Tomcenc

New Member
Messages
57
Reaction score
0
Points
0
I'll have to ask it after I get a domain and paid hosting then. Thanks anyway.
 
Status
Not open for further replies.
Top