Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

.htaccess question

  • 15-01-2008 04:16PM
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    hi

    i want to redirect all requests comming into my site as http://domain to http://www.domain
    that would be simply the below in a htaccess file :
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
    

    however i want to unsure that all https:// requests actually have no www. therefore like this https://mydomain.com
    therefore if a https is called for and a www. exists then it gets redirected to url without www.
    anyone know how to do the last part ?

    cheers


Comments

  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    in fact if i do the below the script will stall cos it runs into a loop
    redirect 301 /sc/category/machines-8/desc/id/page-1.html http://www.xxxx.com/sc/category/machines-8/desc/id/page-1.html
    


    and this will not work

    redirect 301 http://xxxx.com/sc/category/machines-8/desc/id/page-1.html http://www.xxxx.com/sc/category/machines-8/desc/id/page-1.html
    


    anyonw know how to sort that ?


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    anyone ?


  • Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭tomED


    I do this for other domains we have, u should be able to hack it! ;)
    If not let me know and i'll do it for ye.

    RewriteCond %{HTTP_HOST} ^(www\.)?2bscene\.eu$
    RewriteRule (.*) http://www.2bscene.ie/$1 [R=301,L] 
    

    EDIT: Ooppss just noticed the bit about https, I have something done somewhere else, will dig it out.


  • Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭tomED


    I couldnt find that site that i did it on before, but from memory i checked to see it the SSL was off and redirected accordingly,

    RewriteCond %{HTTPS} off


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$
    RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
    


    Hi,

    i tried using this - but i get an internal server error !

    any ideas on that or in fact on my second post ?


    cheers


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,452 ✭✭✭tomED


    weird, you have the "RewriteEngine On" I'm assuming?


  • Registered Users, Registered Users 2 Posts: 648 ✭✭✭ChicoMendez


    yes indeed its on - strange alright

    im using other 301 redirects in the .htaccess file so the rewrite engine is on alright.


Advertisement