Motive
Motive

Reputation: 3111

How to change localhost/site to site.dev

I use XAMPP for local development and I've heard of developers that change the url structure from localhost/site to site.dev, but I'm not sure how to go about it.

How can I change it and is there anything I should know before changing it?

Upvotes: 0

Views: 5955

Answers (2)

Musa
Musa

Reputation: 97717

You'll need to add an entry in your host file to map site.dev to localhost

127.0.0.1 site.dev www.site.dev

and add a virtual host in apache to detect it

<VirtualHost *:80>
    DocumentRoot /path/to/document/root/site/
    ServerName site.dev
    ServerAlias  www.site.dev
# Other directives here
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /path/to/document/root/
    ServerName localhost
# Other directives here
</VirtualHost>

Upvotes: 1

Chris McGrath
Chris McGrath

Reputation: 1767

You can point site.dev to 127.0.0.1 in your hosts file and create a binding for the url in the apache config file so that requests from that url point at a specific site/folder in xampp. I've done this in the past for development projects and generally works pretty well.

Upvotes: 1

Related Questions