• Hello,

    I have the following problem. On my site it seems that certain (AJAX) scripts do not work when the www is left out of the URL.
    in other words, if a request is executed in a page that has URL
    ‘www.foobar.com/foo/bar/’ ==> the sript works OK
    If the page URL is
    ‘foobar.com/foo/bar/’ ==> The script does not work.

    How can I rewrite the URL so that it is always prefixed with www.

    Thanks for your help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Place the following in your .htaccess file right after this line:
    <IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1 [R,L]

    Just change the domain.com to match your URL

    Hope it helps ??

    Thread Starter pascalou127

    (@pascalou127)

    Thank you.
    I’ll give it a try.

    hi! i have the same problem i want to redirect so mydomain.com is always www. mydomain .com to avoid doble content, but this doesnt work : (

    Should i delete the “RewriteBase / ” before ” RewriteEngine On” to write what this guy says
    “RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
    RewriteRule ^(.*)$ domain.com/$1 [R,L]”

    here is my htaccess file

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    Put it direct after RewriteEngine on.

    Hello,
    i have a similar problem. I have the wordpress blog in an extra folder. Like this domain.com/blog/. I tried the redirect tips above and i gives me an Error 500.
    I have a normal website at *www.domain.com* and there a 301 redirect when someone uses domain.com to redirect to *www.domain.com*, and that works. But when i use domain.com/blog/ it does not work for that. Now i tried some different redirect tips i got in the blog htaccess, but nothing works. Can please somebody tell me exactly what to write in my htaccess to get it work? And please dont just say put this there, i tried so much to put this there and nothing worked. Please when possible give me a complete example. Here is my htaccess file without changes i tried before, and thank you for your help.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>

    # END WordPress

    If someone cares, here how i solved the problem. I had to delete the htaccess in the wordpress folder and put this htaccess in my root. So both the root and the folder where wordpress is are redirected correctly to my www′s

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.domain\.de$
    RewriteRule ^(.*) https://www.domain.de/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^blog/ /blog/index.php [L]
    </IfModule>

    # END WordPress

    I have a similar problem that BBSpirit had…but when I make the changes to my htaccess wordpress seems to revert the file back to the standard wordpress htacccess? What is causing that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Re-direct site URL’ is closed to new replies.