Jump to content

[SOLVED] fake subdomains


alexweber15

Recommended Posts

searched both the forums and google and haven't found anything that works...

 

here's the deal (and i can see this is pretty popular too):

 

URL: one.mydomain.test

REDIRECT: mydomain.test/redir.php?sub=one

 

and so on... whatever the subdomain used i want it to be passed as a GET variable to the file redir.php

 

i'm running xampp on windows and i've already set up a virtual host and enabled ServerAlias *.mydomain.test and www.mydomain.test works fine

 

here's my htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mydomain\.test
RewriteCond %{HTTP_HOST} ([^.]+)\.mydomain\.test
RewriteRule ^(.*)$ /redir.php?sub=%1 [R,L]

 

whenever i try to access any subdomain (or even just mydomain.test - without the www) i get a page not found error...

 

can anyone please help?

Link to comment
https://forums.phpfreaks.com/topic/152019-solved-fake-subdomains/
Share on other sites

This is what I used for my fake subdomains and it works

I had to get my hosting company to set up a wildcard on the server for it to work though.

 

RewriteCond %{HTTP_HOST} ([^/]+).mydomain.co.uk [NC]
RewriteCond %1 !www$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/some_page.php?variable=%1 [L]

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.