Jump to content

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]

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.