LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-23-2006, 06:27 PM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
forcing www.mydomain.com to just mydomain.com


I'm wondering how I might alter my apache2 config so that visitors to www.mydomain.com get immediately redirected to just mydomain.com (or vice versa).

does anyone know a quick and easy way to do this?
 
Old 07-23-2006, 10:08 PM   #2
hobbestec
LQ Newbie
 
Registered: Nov 2003
Location: Boston, MA
Distribution: Debian, Ubuntu, Fedora
Posts: 27

Rep: Reputation: 15
Use the Redirect directive in Apache, such as:

<VirtualHost>
ServerName: www.mydomain.com
Redirect / http://mydomain.com
</VirtualHost>

<VirtualHost>
ServerName: mydomain.com
DocumentRoot blah blah blah etc...
</VirtualHost>

http://httpd.apache.org/docs/2.0/mod....html#redirect
 
Old 07-23-2006, 11:04 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
THANKS for the tip, but it doesn't seem to work for me. I'm using apache2.

here's what the top of my conf file for that domain looks like:

Code:
NameVirtualHost 111.222.333.444:80
NameVirtualHost 111.222.333.444:443

<VirtualHost>
ServerName www.mydomain.com
Redirect / http://mydomain.com
</VirtualHost>

<VirtualHost 111.222.333.444:80>
    ServerAdmin me@mydomain.com

        DocumentRoot /home/mydomain/public

        ServerName mydomain.com

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/mydomain/public/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                # RedirectMatch ^/$ /apache2-default/
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
 
Old 07-24-2006, 01:56 AM   #4
slantoflight
Member
 
Registered: Aug 2005
Distribution: Smoothwall
Posts: 283
Blog Entries: 3

Rep: Reputation: 35
Forget apache confs. Besides it won't work that way. Thats not virtual hosts are for. You have to configure a dns. And thats NOT simple.

Try this instead.

<META HTTP-EQUIV=REFRESH CONTENT="2; URL=http://www.example.org/bar">

put in the head of your html file.
 
Old 07-24-2006, 02:23 PM   #5
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
slanto, unfortunately, i don't think your solution is very helpful. were i to put that in my index.html page, it would constantly redirect to itself, wouldn't it?

Additionally, what if someone were to type in http://mydomain.com/foo

that page would not be armed with redirect.

I think apache redirect is the way to go.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
localhost VS mydomain.net thisObject Linux - Software 5 05-07-2006 07:56 PM
can't access www.mydomain.net thisObject Linux - Software 12 04-17-2006 05:47 PM
How to make PHPBB not show a directory listining www.mydomain.com/phpBB2/ fur Linux - Networking 3 04-26-2004 07:17 PM
Ping mydomain.com bulzbb Linux - Networking 7 03-16-2004 05:42 AM
mail.mydomain.com does not work saravanan1979 Linux - Networking 8 02-01-2002 10:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:55 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