Mobile app version of vmapp.org
Login or Join
Nimeshi995

: How to fake domain on OS X? I have added an entry to my hosts file which allows me to have localhost URLs like the following: http://mydomain.dev/~macuser/mydomain/index.php But I would

@Nimeshi995

Posted in: #Apache #Localhost

I have added an entry to my hosts file which allows me to have localhost URLs like the following:


mydomain.dev/~macuser/mydomain/index.php

But I would like to somehow map this host entry to achieve the following instead:


mydomain.dev/index.php

Where 'index.php' lives at the path '~/Sites/mydomain/index.php'.

Is this possible? how to do this?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Nimeshi995

2 Comments

Sorted by latest first Latest Oldest Best

 

@Turnbaugh106

Editing MAC's host file

You will first need to edit your operating systems host file, on a mac this is a rather simple procedure that you should be able to follow with ease.


Open your terminal application (normally /Applications/Utilities/Applications.app or you can may even perfer to use your standard text editor.
In the terminal type nano /private/etc/hosts or open that file using your editor.
Add 192.168.1.1 example.com #Add a comment if you wish here to your hosts file, save it by doing control + o or save as within your editor.
Now that your operating system hosts file has the nessacary changes you most likely need to flush your DNS by doing dscacheutil -flushcache


Adding your virtual host

You then need to instruct your HTTPD server that you have a domain that you want to attach to the server, this is referred as a virtual host. In this example we look at Apache and setting a example domain (there is dozens of questions and answers on virtual hosts on Pro Webmasters already.

You can add the virtual hosts by going into your enabled sites and editing the configation file and adding something like:

<VirtualHost *:80>
ServerName example.com
DocumentRoot "/Users/myusername/Sites/Test/public"
<Directory "/Users/myusername/Sites/Test/public">
Options Indexes FollowSymLinks Includes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


It's worth mentioning there are plently of tutorials on YourTube which will work you through setting up a LAMP.

10% popularity Vote Up Vote Down


 

@Sims2060225

It's possible, yes. Either you can:


change your httpd to redirect your URL. In apache that's with mod rewrite
Create a reverse proxy that redirects incoming URLs and rewrites.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme