Tag : apache-2

Redirect from www to non www using apache htaccess

Redirect from www. to non www


RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

XAMPP – Create subdomain (virtualhost)

Edit Apache Config

The file is located “c:xamppapacheconfextrahttpd-vhosts.conf”:

Add this lines if not already exists:


<VirtualHost 127.0.0.1:8080>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
ServerAdmin admin@localhost
</VirtualHost>

Then add the following to have “c:xampphtdocssub.domain.com” point to http://sub.domain.com.localhost/:


<VirtualHost subdomain.localhost>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /home/httpd/htdocs/subdomain/
ServerAlias subdomain.localhost
</VirtualHost>

Edit HOSTS File

You can find your HOSTS file in the “C:WindowsSystem32driversetc” directory

Open it up in a text editor, and add the following lines:


127.0.0.1 subdomain.localhost