LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-02-2010, 02:27 AM   #1
cparapat
LQ Newbie
 
Registered: Jun 2010
Location: Indonesia
Distribution: Mac OS X, Centos, OpenSuSE, Redhat, FreeBSD.
Posts: 26

Rep: Reputation: 0
How to make auto replace http url in a web server.


Hi all,
I setting up a web server on my Linux (Centos) using "Apache" web server. And its working well, it will show my websites. But when i try to put my url in a internet browser (ie. only type "myweb.com" ) is only be http://myweb.com. Usually as i know like the other websites (ie. google.com) it will go to auto replace the name be "www.myweb.com". But my url here it's not be replacing like that. How to do this configuration. I don't know where the services that i need to look. (ie; named (bind) or in Apache web server it self) ? Sorry for my english bad.

Last edited by cparapat; 07-02-2010 at 03:53 AM.
 
Old 07-02-2010, 02:57 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi and welcome to LQ,

First you must make sure that both myweb.com and www.myweb.com resolve to the same IP. You can check it by running:
Code:
host myweb.com
host www.myweb.com
If the don't match you need to talk to the dns admin so he makes an alias.
Then you need to use mod_rewrite in apache
Code:
RewriteEngine on
RewriteCond %{HTTP_HOST}   !^www.myweb.com [NC]
RewriteRule (.*)         http://www.myweb.com/$1 [L]
You can put the above into httpd.conf, or in a .htaccess file in /var/www/html

Regards
 
Old 08-15-2010, 11:58 AM   #3
cparapat
LQ Newbie
 
Registered: Jun 2010
Location: Indonesia
Distribution: Mac OS X, Centos, OpenSuSE, Redhat, FreeBSD.
Posts: 26

Original Poster
Rep: Reputation: 0
Hi Bathory,

Thank you for your helps. Ya, you right. I try to do this with hard until finished it now . It could be working with mod_rewrite modules. My Web server was working good now for the url. But in my addition, i used "nginx" as my web load balancing. And I do the rewriting url that nginx have. But my node used apache web server. Thank you very much for your help Bathory.

Cheers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you make search ...search a string in a link....a url...a web address aus9 LQ Suggestions & Feedback 4 04-16-2008 09:37 AM
Monkey HTTP Daemo (web server) Thulemanden Linux - Server 1 10-12-2006 05:19 PM
HTTP Web Server Not Saving Changes goldcougar Linux - Newbie 5 06-28-2004 03:30 PM
Problems accessing my RH9 Apache web server from the URL! kman2045 Linux - Networking 7 01-10-2004 08:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration