0

I have setup virtual host on my localhost by using codeigniter and it is working fine. But I am not able to create wildcard subdomains. To add virtual host below are my steps on windows machine.

C:\Windows\System32\drivers\etc\hosts.txt

In this host.txt I have added below line

127.0.0.1           localhost.com

I am using xampp .I have added below lines in httpd-vhosts.conf file. D:\xampp\apache\conf\extra\httpd-vhosts.conf

<VirtualHost localhost.com:80>
    DocumentRoot "D:/xampp/htdocs/adeptra"
    ServerName localhost.com
    ServerAlias localhost.com

    <Directory "D:/xampp/htdocs/adeptra">
        Options Indexes FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/adeptra"
    ServerName localhost.com
    ServerAlias *.localhost.com
<Directory "D:/xampp/htdocs/adeptra">
        Options Indexes FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>

Below is my .htaccess code to remove index.php

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

So now my question is, is it really possible to create wildcard subdomains in localhost? If yes, then please help me in this regard. Any help would be greatly appreciated.

user3408779
  • 981
  • 2
  • 19
  • 43

1 Answers1

0

A similar question has already been asked and answered here. Basically, no you cannot create subdomains on localhost. You need to create a local domain which is explained in the linked answer.

Stanley
  • 46
  • 5