+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: 301 Redirect from non-www To www URL (real estate)

  1. #1
    Senior Member
    Join Date
    Aug 2010
    Posts
    174

    301 Redirect from non-www To www URL (real estate)

    I'm wondering how I can perform 301 redirect from ‘non-www’ to ‘www’ URLs in Real Estate.
    I want all my URLs to be with ‘www’ prefix.

    Thanks.
    Last edited by PGGO; June 29, 2012 at 07:48 PM.

  2. #2
    Junior Member
    Join Date
    Aug 2011
    Location
    Romania
    Posts
    10
    you can use .htaccess file if the script it not doing this allready

    ---- .htaccess file example ----
    RewriteEngine On

    #force non-www to www

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

    #force non-ssl to ssl

    RewriteCond %{SERVER_PORT} !^443$.
    RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]

    ---- .htaccess file end example ----

    T.Bogdan
    SysAdmin

  3. #3
    Senior Member
    Join Date
    Aug 2010
    Posts
    174
    It does not work for version 4.0.
    I'm not even able to access my website with ‘www’ prefix.

  4. #4
    Junior Member
    Join Date
    Aug 2011
    Location
    Romania
    Posts
    10
    then the problem may be elsewhere

    first you must check that your host www config is ok ( if you use a vhost then ask your sys admin to check it ). That mean anything you put in your site directory can be accesed by your calling desire hostname. So if your www directory is for examble /home/your-user/public-www and you put there a file called my-file.html then you call that file http://www.your-host.org/my-file.html the response must be positive. If you can call your file only by http://your-host.org/my-file.html and with http://www.your-host.org/my-file.html not then the problem is in the virtualhost config and you ( or your sysadmin ) must config the virtualhost properly

    T.Bogdan
    SysAdmin

  5. #5
    Senior Member
    Join Date
    Aug 2010
    Posts
    174
    Thanks Bogdan for your suggestion; however, I’m not sure how to perform such changes.

    I checked ‘index.php’ file in root directory, and have found the code below.
    Does this may cause this issue?



    /* www prefix detecting */
    $redirect_host = explode('/', RL_URL_HOME);
    $redirect_host = 'http://'.$redirect_host[2].'/';

    if ( false === strpos($_SERVER['HTTP_HOST'], 'www') && false != strpos(RL_URL_HOME, 'www') )
    {
    $request_url = ltrim($_SERVER['REQUEST_URI'], '/');
    header("Location: ". $redirect_host . $request_url);
    }
    elseif ( false !== strpos($_SERVER['HTTP_HOST'], 'www') && false === strpos(RL_URL_HOME, 'www') )
    {
    $request_url = ltrim($_SERVER['REQUEST_URI'], '/');
    header("Location: ". $redirect_host . $request_url);
    }

  6. #6
    Hello Petnax,

    If you want use your site with www and system should redirect you to www you can go to:
    ftp:includes>>config.inc.php
    find line:
    Code:
    Only registered members can view the code.
    add www. in your site name.
    Viktor,
    Flynax technical department,
    Best wishes.

  7. #7
    Senior Member
    Join Date
    Aug 2010
    Posts
    174
    Viktor,
    Thanks for the info, it works!

    In addition, I have notice a ‘302 redirect‘ from non-www to www.
    Q: can I add a ‘301 redirect’ instead of 302 ?

    It will help for SEO a bit.

  8. #8
    Hello Petnax,

    Please open file ftp://index.php
    find:

    Code:
    Only registered members can view the code.
    in top of file and after it add new:

    Code:
    Only registered members can view the code.
    I think it should solve it
    Viktor,
    Flynax technical department,
    Best wishes.

  9. #9
    Senior Member
    Join Date
    Aug 2010
    Posts
    174
    Quote Originally Posted by Viktor View Post
    in top of file and after it add new:

    Code:
    Only registered members can view the code.
    Viktor,

    Would you please explain more detailed?
    Cause, it’s not clear to me, at which line I should add this line of Code “header( "HTTP/1.1 301 Moved Permanently" );”

  10. #10
    Hi,

    Easiest thing is to have domain name with www in the includes/config.inc.php file

    Then system will redirect all pages to www.

    in addition to this you can put rewrite rule to htaccess file


    Code:
    Only registered members can view the code.
    4.1 software version asks how you want your website to be - with www or without during installation

+ Reply to Thread