0

I want to assign a Specific subdomain to each user after registration based on her Username on the local wampServer for a domain like tc.dev

I've done all steps that been said in This Topic or other similar topics on the web.

This is configuration that i added to httpd-vhosts.conf file:

    <VirtualHost *:80>
DocumentRoot "D:/wamp/www/tc/public/"
ServerName tc.dev
ServerAlias *.tc.dev
<directory "D:/wamp/www/tc/public/">
    Options Indexes FollowSymLinks
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from all
</directory>
</VirtualHost>

And this is what I added to C:\Windows\System32\Drivers\etc\hosts file :

127.0.0.1   tc.dev  
127.0.0.1   *.tc.dev

and this is My route :

Route::group(['domain' => '{account}.tc.dev'], function () {
        Route::get('/', function ($account, $id) {
            return view('main.pages.user.index');
        });
    });

tc.dev works fine but any subdomain that I test does not work and index view not shown.

what is problem and solution?

Update:

According to Wildcards in a Windows hosts file , now sub-domain works as main domain But based on route that I wrote main.pages.user.index does not show and index.php file in DocumentRoot "D:/wamp/www/tc/public/" Is shown.

It seams this route does not consider.

Community
  • 1
  • 1
Ahmad Badpey
  • 6,348
  • 16
  • 93
  • 159
  • 1
    Not too familiar with windows lately as I'm on ubuntu, with nginx but I did find this -- http://stackoverflow.com/a/25391876/1970955 -- you may need to create a PAC file... – PatrickCurl Dec 05 '15 at 11:37
  • You cannot use wildcards in your host file. But there are other thirdparty softwares out there which creates a custom dns, and allows wild cards. Try them. Or you can manually create a virtual host easily with this batch script i wrote a few months ago. If you would like to try it, here is the link https://github.com/mln-mln-mln/Wamp-Virtual-Host-Creator – Milan Maharjan Dec 05 '15 at 14:29
  • @MilanMaharjan,I try your batch script , main domain (`tc.dev`) works fine but a sub domain like `test.tc.dev` does not work and give me `Forbidden` error. Should I also do extra work in addition to your script ? – Ahmad Badpey Dec 07 '15 at 13:50
  • did you setup the host and httpd-vhost file path correctly by editing the script? can you check if the virtual host entry was correctly added to the vhosts file? – Milan Maharjan Dec 07 '15 at 14:22

1 Answers1

0

Finally after Many research and try different ways I could solve problem.

after using Acrylic DNS Proxy , I must use two different root for main and sub domains .

This for Main Domain :

// Match my own domain
Route::group(['domain' => 'tc.dev'], function()
    {
    Route::any('/', function()
    {
        return 'My own domain';
    }); 
}); 

And another for handling subdomains :

Route::group(['domain' => '{subdomain}.tc.dev'], function()
{
    Route::any('/', function($subdomain)
    {
        return 'Subdomain ' . $subdomain;
    });
});

In fact The main thing was that I must to use another Route to control routes that acts On main Domain While I was ignored.

Community
  • 1
  • 1
Ahmad Badpey
  • 6,348
  • 16
  • 93
  • 159