Is there any possibility to add a prefix before localhost?
My question is that I want to add a prefix before localhost for my project url (ie. "dev.localhost/project/default.htm"). This is for an ASP.NET application running in IIS.
closed as off topic by Glenn Nelson, Walter, Yannis♦ Dec 8 '12 at 13:22
Questions on Programmers Stack Exchange are expected to relate to software development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.
Yes, this is possible, depending on the webserver you use.
For Apache you can create a virtual host config.
You can do it like this:
Further, you'll hav to put an entry in your hosts file to redirect to 127.0.0.1.
I'm sorry, but the short answer is no. A URL has a specific defined format of:
so in your example, the protocol is implied as HTTP, there is no username, the host is localhost, its using port 80, the default for HTTP, and the file path is /project/default.htm. It makes more sense to use the path part to diferentiate the different project locations.
The longer answer, is yes, but this depends on how you are hosting your project URLs. The HTTP protocol identifies the host part of the URL when it makes the request to the server. Some Web servers then use this to serve multiple sites from the same computer. (think web hosting companies running multiple customer websites on a single server). This means you could create multiple hostnames for your computer, and then configure the webserver to reference different projects based on the hostname used to connect to. not sure that dev.localhost is a good idea, dev-localhost may well work better, with an entry in /etc/hosts to identify its ip address as 127.0.0.1