Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Redirecting from www cname not working

Options
  • 16-06-2012 2:57pm
    #1
    Registered Users Posts: 4


    Hi Webmaster experts,


    I have installed apache on my windows machine and trying to do a redirect from my site URL http://www.fromdev.com to http://fromdev.com.
    We are trying to do this for mobile devices and want to read the type of device accessing it. However this keeps failing and we are not sure how to debug this. I am new to apache so please feel free to point me to a beginners tutorial or reference site. I have tried some Google search however the information is overwhelming.
    Please feel free to move this thread to right location just in case I have posted this in the wrong place. Thanks in advance.


Comments

  • Closed Accounts Posts: 27,857 ✭✭✭✭Dave!


    Are you using DNS (CNAME) to redirect, or are you using .htaccess (Apache)? You mention both, so I'm not sure what your current setup is.

    Your DNS should be:

    A record - yourdomain.com - 89.123.456 (IP Address)
    CNAME - www.yourdomain.com - yourdomain.com

    Shouldn't be any need for htaccess stuff


  • Registered Users Posts: 45 irishd


    ... trying to do a redirect from my site URL http://www.fromdev.com to http://fromdev.com

    This is known as hostname canonicalization and is usually done using mod_rewrite in httpd.conf or .htaccess.

    Unfortunately the previous poster's DNS setup won't achieve this on its own.

    Something like:
    RewriteEngine On
    RewriteCond %{HTTP_HOST}   ^www\.fromdev\.com [NC]
    RewriteRule ^(.*)$  [url]http://fromdev.com/$1[/url] [R=301,L]
    

    should do the trick

    As regards detecting device type & doing this only for mobile devices, it is a bit more complex. The HTTP_USER_AGENT CGI variable will contain most of the information you need, but doing this in a .htaccess file would tedious because of the number of different devices & user-agents available.

    Most likely you will need either javascript code, or some server-side code (PHP, ASP.Net etc etc) to get this right.


  • Registered Users Posts: 4 AnishaTiczon


    Sorry for the confusion in the question, I meant I am using Apache on my server for redirecting.

    Thanks for the answer. I will try it and let you know if works.


  • Registered Users Posts: 4 AnishaTiczon


    DAve, I have not tried your idea yet. However it looks much cleaner. I dont want to get complex solution, I guess it may work. Will try at my godaddy total dns dashboard.

    Thanks, it will also save me a unwanted maintenance on apache side.


  • Registered Users Posts: 4 AnishaTiczon


    I guess I am getting too greedy here, however just wanted to ask in case you are already aware. Does any of this solution have impact on SEO of my site.

    I mean, I want to make sure there is always one of these urls used by the search engines not both.


  • Advertisement
  • Registered Users Posts: 45 irishd


    I want to make sure there is always one of these urls used by the search engines not both.

    That is exactly what the 301 redirect should achieve.


Advertisement