Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Htaccess redirection

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #46373
    Epy
    Participant

    Hello all !
    I’d like some help for something that bugs me a little

    I’m trying to redirect my visitors from:

    http://example.com/ to http://example.com/www AND displaying http://www.example.com in address bar

    I already have a .htaccess redirection from:

    http://example.com to http://www.example.com
    but it also let visitors go to:
    http://mysubdomain.example.com without redirecting them
    (If subdomain doesn’t exists I get a “page doesn’t exists” error from browser)

    I only have a shared hosting so I used the webinterface to create and manage subdomains redirections (it works well). I don’t have access to other related parameters. I have to use htaccess

    Here it is:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^domaine.net$
    RewriteRule ^(.*) http://www.domaine.net/$1 [QSA,L,R=301]

    Someone has a clue ?

    Thanks !

    #142689
    georgearnall
    Participant

    I am not sure this is possible… Why are you trying to redirect visitors to http://example.com/www ? Wouldn’t it be easier to move the contents of this folder to the root directory ?

    #142696
    Epy
    Participant

    Because my CMS is installed in this www directory.
    I think it would be really messy to install its index.php and all other directories in root :/

    May I redirect http://example.com to http://example.com/www with a php file in root
    and have it rewrited to http://www.example.com with htaccess file ?

    Thank you

    #142728
    Epy
    Participant

    That’s what I was thinking, redirecting to /www and rewriting url (but could it be a problem for search engines ?)

    #142773
    Epy
    Participant

    I was thinking about SEO while reading your answer, I read about Google recommandations, to avoid “punishment” in search answers and they say to choose between with www and without, but if you say I can use this trick why not :)

    The problem is I can’t redirect EVERYTHING to www/ because I have subdomains, they will redirect to /www too

    The RewriteBase should be the full path to where the htaccess file is, or to the root directory of my website (root directory of the CMS in this case) ?

    #142993
    Epy
    Participant

    Thank you !
    I’ll try soon

    #145308
    Epy
    Participant

    Hello

    Sadly this doesn’t work, actually the redirections are OK as they were before: I keep the subdomains redirections (projets.domain.com still goes to /projets, etc.) and the “no-www” to “with-www”

    But my visitors won’t go to the /www directory automatically
    I have to find a good way to do that

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Other’ is closed to new topics and replies.