Multiple Of The Same Domain - Redirect

Discussion in 'Web Hosting and Domain Names' started by mojo8850, Sep 28, 2012.

to remove all ads.
  1. mojo8850

    mojo8850 New Member

    Messages:
    10
  2. AsheSkyler

    AsheSkyler New Member

    Messages:
    177
    Yes, it's possible. Please tell me you're really here for help and not to advertise happy hour for the one eyed wonder worm.
     
  3. mojo8850

    mojo8850 New Member

    Messages:
    10
    I swear I'm not advertising here.
    I need this fixing how can I do this..

    When all the above are typed in the address bar by user I want them all to transfer to
    https://www.**********.co.uk

    If you think I'm advertising I'll use asterisks if you wish.
     
  4. AsheSkyler

    AsheSkyler New Member

    Messages:
    177
    Nah, don't worry about censoring. I just get suspicious easy since some folks post once and we never see them again.


    What I did on my site was something similar to this, right below the "RewriteEngine on" part:

    RewriteCond %{http_host} ^stiffnights.co.uk [nc]
    RewriteCond %{http_host} ^www.stiffnights.co.uk [nc]
    RewriteRule ^(.*)$ https://www.stiffnights.co.uk/ [r=301,nc]

    It worked for me and will redirect regardless if the user types in "http://" or not, but I wasn't working with secure pages. You'll definitely want to test it.
    I tried looking around for an exact answer, but like all other things related to coding, there is no one standard method.
     
  5. mojo8850

    mojo8850 New Member

    Messages:
    10
    Thank you skyler..

    The links don't redirect to https;//www.stiffnights.co.uk
    If I type stiffnights.co.uk it don't redirect

    Wonder what it is.
     
  6. AsheSkyler

    AsheSkyler New Member

    Messages:
    177
    The blind leading the blind?

    Try this:
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.stiffnights.co.uk/$1 [R,L]
     
  7. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,611
    Ashe's solution will work but take note that if you have any subdomins they will ALSO be redirect to https://www.domain.tld


    Also to avoid appearing to be link dropping to your Internet properties, ESPECIALLY ones that are inappropriate for forums such as this, use a dummy name for the domain name.

    We do not need the actual name of the domain for a generic question such as this, domain.tld will suffice.
     
  8. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,611
    Oh and to prevent auto-linking there is a checkbox under the post editor (full editor NOT the quick post) that says "Automatically parse links in text", by unchecking that it will leave URLs as plain text.
     
  9. mojo8850

    mojo8850 New Member

    Messages:
    10
    Ok sorry I will remember that..

    So you think ash's code will work?
     
  10. mojo8850

    mojo8850 New Member

    Messages:
    10
    Ok after a little organizing this is my result.

    My .htaccess file is as follows:-
    Now the results:-
    mydomain.co.uk ---> transfers to www.mydoamin.co.uk
    mydomain.co.uk/ ---> transfer to https://www.mydomain.co.uk

    www.mydoamin.co.uk ---> same no change www.mydoamin.co.uk

    http://mydomain.co.uk ---> transfers to www.mydomain.co.uk

    Now I think I have found out why it playing funny.
    If all of these are type in as follows:

    http://mydomain.co.uk/
    https://mydomain.co.uk/
    www.mydomain.co.uk/
    mydomain.co.uk/
    http://www.mydomain.co.uk/

    They all transfer to https://www.mydomain.co.uk.
    The problem is a forward slash has to be present for the redirect to work.

    Is it possible to leave the .htaccess code the way it is and add more code so when the domains are typed in the address bar with out the forward slash they will also work to.

    Hope this is useful sorry for being a pest but I have to resolve this.

    Thank you
     
  11. AsheSkyler

    AsheSkyler New Member

    Messages:
    177
    I honestly don't know enough to know why the slash is important and I haven't found anything that would say why it's not working.

    Thank you! I forgot all about that checkbox. That auto-linking was driving me nuts. I spent a few edits before posting trying to remove the BBC tags before I gave up.
     
    Last edited: Sep 29, 2012
  12. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,611
    It will be some conflict possibly because of the two duplicated rewrite conditions, .htaccess works by creating an internal request for the new URI, but a missing trailing slash ALSO makes a new request after adding the slash so they are falling over each other.

    Try this
    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
    Which is a "force HTTPS" ruleset and will work with or without a trailing slash.

    What that does is check the protocol being used rather than matching characters in the URI.
     
  13. mojo8850

    mojo8850 New Member

    Messages:
    10
    Wooohoooo Its Working Awesome Friend's Thank You Soooooo Much..

    The Code Above Worked With A Little More Of A Revamp. Awesome ;)
     
  14. mojo8850

    mojo8850 New Member

    Messages:
    10
    Ok.. Now a minor problem.. LOL

    My current htaccess file is as follows..

    All The https:// Redirects work perfect.

    BUT I have 1 sub domain that also transfers to https://

    I don't want to http://forum.mydomain.co.uk to transfer. But I want to leave the others.
     
  15. mojo8850

    mojo8850 New Member

    Messages:
    10
    Sorry to say friends I figured it out :D
     
  16. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,611
    For future readers will you provide the final solution?
     
  17. mojo8850

    mojo8850 New Member

    Messages:
    10
    Of course.. Knowledge is something I like to share.. I will help ;) :D
     
  18. eco291

    eco291 New Member

    Messages:
    1
    Como se puede redireccionar dominio

    hola soy nuevo en internet y quisiera redireccionar un dominio como puedo realizarlo http://solocontactosgay.es/
     
  19. chrishirst

    chrishirst Well-Known Member Staff Member

    Messages:
    2,611
    Hasta la vista culo!


    Or maybe

    adiĆ³s culo!
     
  20. AsheSkyler

    AsheSkyler New Member

    Messages:
    177
    EWWWWWWWWWWWW pornbot! I never thought I'd miss spambots...

    I'll have to remember next time that "gay" means the same thing in both English and Spanish.
     

Share This Page