Results 1 to 16 of 16
  1. #1

    Redirect example.com to www.example.com

    I have multiple domains on my web server. One of my domains does not display its website when using example.com in the location bar.

    Eg. example.com redirects to site2.com but www.example.com displays properly.

    I tried adding to the htaccess file:

    Options +FollowSymlinks
    RewriteEngine on

    RewriteCond %{HTTP_HOST} !^www\.example\.com
    RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
    It doesn't work. The redirect does not occur.

    Any idea how do i fix this?

  2. #2
    Options +FollowSymlinks
    RewriteEngine on

    RewriteBase /
    RewriteCond %{HTTP_HOST} !^example.com$ [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

    in this code I use it redirects www.example.com to example.com

    maybe that would help....but I think you want to reverse what I do.
    IPNeighbor.com - See who you share Your Web server with.
    BuildAServer.info Build a 1U server

  3. #3
    That's just a small variation of what i tried (redirect is different). I tried it anyways and it didnt work either.

  4. #4
    Join Date
    Jun 2003
    Location
    World Wide Web
    Posts
    581
    Can you provide the results of following commands

    dig example.com

    dig www.example.com
    SupportExpertz.com - the name says it all!
    Managed Cloud Servers
    Server Management and Monitoring
    24x7 outsourced customer support

  5. #5
    Code:
    dig mytempmail.com
    
    ; <<>> DiG <<>> mytempmail.com
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 1081
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;mytempmail.com.                        IN      A
    
    ;; Query time: 296 msec
    ;; SERVER: 64.15.64.91#53(64.15.64.91)
    ;; WHEN: Sun Aug 02 00:42:50 2009
    ;; MSG SIZE  rcvd: 32
    Here's my zone file:

    Code:
    $TTL 86400   ; Default TTL in secs(1 day)
    @  IN  SOA  ns1.mytempmail.com. info.mytempmail.com. ( 
                  		  2009080101	; serial number YYMMDDNN
                            28800           ; Refresh
                            7200            ; Retry
                            864000          ; Expire
                            86400           ; Min TTL
                  )
    mytempmail.com.  					NS   			ns1.mytempmail.com.
    mytempmail.com.  					NS    		ns2.mytempmail.com.
    mytempmail.com.  					MX    10 	mail.mytempmail.com.
    mytempmail.com.  					A     			67.212.80.44
    ns1            								A     			67.212.80.44
    ns2            								A     			67.212.80.44
    www           								CNAME 	ns1
    mail          									A     			67.212.80.44
    												A     			67.212.80.44
    www           								CNAME 	mytempmail.com

  6. #6
    If my example did not work for you maybe your apache is not enabled for htaccess in apache config file for that domain.
    .
    maybe you need the

    AccessFileName .htaccess

    in the apache config file
    IPNeighbor.com - See who you share Your Web server with.
    BuildAServer.info Build a 1U server

  7. #7
    Join Date
    Jun 2003
    Location
    World Wide Web
    Posts
    581
    The domain should point / resolve to your server properly. From the "dig" result its shows that the domain is reaching the nameservers but for some reason its not resolving completely.

    Confirm whether you have made any recent changes at your domain name registrar.

    Also the zone file entry should complete with a dot (.) as follows

    www IN CNAME mytempmail.com.
    SupportExpertz.com - the name says it all!
    Managed Cloud Servers
    Server Management and Monitoring
    24x7 outsourced customer support

  8. #8
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    Ugg. Don't use CNAME, just do an A record. CNAME causes two queries to find the IP.
    Just darn ugly. It has it's place, but not where you can just as easily do an A rec.
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

  9. #9
    I added that directive and htaccess override still doesnt work. Other htaccess things work though.

  10. #10
    As for the .htaccess code , try this :

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^mytempmail.com/$ [NC,OR]
    RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^www.mytempmail.com/$ [NC]
    RewriteRule ^(.*)$ http://www.mytempmail.com/$1 [r=301,nc]

  11. #11
    Join Date
    Jun 2003
    Location
    World Wide Web
    Posts
    581
    Jordan,

    Your domain is not resolving to your server properly. You should fix this first, otherwise .htaccess will not make any effect.
    SupportExpertz.com - the name says it all!
    Managed Cloud Servers
    Server Management and Monitoring
    24x7 outsourced customer support

  12. #12
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    You can test this by putting an entry in your c:\windows\system32\drivers\etc\hosts file
    in the form

    IPADDRESS hostname

    like

    192.168.5.5 domain.com
    192.168.5.5 www.domain.com

    Save the file, then ping your domain and make sure it's hitting your actual we server.

    Try again with the browser, if it works, the issue is with you DNS. Fix DNS, remove the two entries in your hosts file.
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

  13. #13
    The DNS resolves fine to the www.mytempsite.com but when going to mytempsite.com it resolves to capturetheprize.com (another site on the same server).

  14. #14
    Join Date
    Mar 2009
    Location
    Austin Tx
    Posts
    2,001
    It sound like your apache directive is setup to answer to www, but not just the mytempsite.com

    Add

    ServerAlias mytempsite.com

    into your <virtualhost> for that domain.
    This is the best signature in the world....Tribute!
    (It is not the best signature in the world, no. This is just a tribute)

  15. #15
    Hye let us know if that solved your problem.. if not lets continue with the possibilities.


  16. #16
    Aha!

    That fixed it. Thanks a million

Similar Threads

  1. Help with 301 Redirect
    By Fizbin in forum Programming Discussion
    Replies: 2
    Last Post: 11-21-2006, 02:29 PM
  2. FTP Redirect?
    By empmdk in forum Web Hosting
    Replies: 6
    Last Post: 11-04-2006, 02:28 AM
  3. IP Redirect / Country Redirect.
    By alma714 in forum Web Hosting
    Replies: 1
    Last Post: 12-25-2004, 03:19 PM
  4. Need help with a redirect.
    By irlhost in forum Hosting Security and Technology
    Replies: 0
    Last Post: 03-12-2003, 01:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •