Solved

IP to name base

Posted on 2004-08-08
10
261 Views
Last Modified: 2010-03-04
I installed Apache server. Let say my IP addr is 123.123.123.123
From the browser I can see the pages by typing http://123.123.123.123/test.htm
Is it possible to setup Apache so it will automaticall convert to name based such as
http://uniqueName/test.htm?

Thanks
0
Comment
Question by:helpJavaGuru
  • 6
  • 3
10 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 65 total points
ID: 11745654
Hi helpJavaGuru,

> Is it possible to setup Apache so it will automaticall convert to name based such as
http://uniqueName/test.htm?
Conversion is DNS functionality ...
To use names instead of IP address, set servername in httpd.conf file

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName uniquename:80

Sunnycoder
0
 

Author Comment

by:helpJavaGuru
ID: 11745757
I already did that before the posting and it didn't work.
I am using Windows xp and I don't have any Domain name server setup.
I installed apache server and enter 127.0.0.1 and I can see the test page.
I enter my computer name http://mycomp/test.htm I can see the page
What I want to accomplish is to enter http://127.0.0.1/test.htm and the browser should see the test page and display http://mycomp/test.htm

Can this be done without a dns server?
0
 

Author Comment

by:helpJavaGuru
ID: 11745764
I believe apache should automatically  convert the entered ip http://127.0.0.1/test.htm to http://whatEverDomainName/test.htm
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11747550
mod_rewrite is your friend

RewriteCond %{HTTP_HOST} ^127.0.0.1$
Rewrite Rule ^(.*)$ http://whatEverDomainName/$1

# to be improved in many ways (just to get you the idea)
0
 

Author Comment

by:helpJavaGuru
ID: 11748758
I the the following lines of codes in .htaccess file

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^127.0.0.1$
Rewrite Rule ^(.*)$ http://whatEverDomainName/$1

When entered http://127.0.0.1/test.htm the 127.0.0.1 didn't change to the doman name I wanted. am I missing something?
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

by:helpJavaGuru
ID: 11748774
The .htaccess file is resided in the same folder where all web pages resided.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 11748895
better write it httpd.conf, or make shure that .htaccess is evaluated
or try:
Rewrite Rule ^(.*)$ http://whatEverDomainName/$1 [RL]
0
 

Author Comment

by:helpJavaGuru
ID: 11748914
So all I needed to do is to open httpd.conf and put the following lines at the bottom of the httpd.conf?

RewriteEngine on
Rewrite Rule ^(.*)$ http://whatEverDomainName/$1 [RL]

It doesn't work when I try this. I am new to the apache server.
0
 

Author Comment

by:helpJavaGuru
ID: 11749018
I think the problem is the R,L
I tried with the following changes:

<VirtualHost *:80>
RewriteEngine On
RewriteRule ^/(.*) http://mydummydomain/$1 [R,L]
</VirtualHost>

when I entered http://127.0.0.1/test.htm it will forwarded to http://mydummydomain/test.htm

This is not exactly what I want, I am doing testing on my computer, I entered http://127.0.0.1/test.htm

I would like it to display http://mydummydomain/test.htm  The mydummydomain is not valid domain name. It's just a dummy name.

Is it because I put the codes in <VirtualHost *:80>? Instead I should put it somewhere else?

Thanks.
0
 
LVL 51

Assisted Solution

by:ahoffmann
ahoffmann earned 60 total points
ID: 11750122
you need these lines (either VirtualHost directive or not, depends on your settings):

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^127.0.0.1$
Rewrite Rule ^(.*)$ http://whatEverDomainName/$1 [R,L]

> The mydummydomain is not valid domain name. It's just a dummy
then it would not work, 'cause the browser tries to resolve that name (R == redirect)

The only way to do what you want is some kind of malware, for example javascript in your page which manipulates the address bar of your browser.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now