Forums

[resolved] Prevent removal of "www" (2 posts)

  1. kingmoge
    Member
    Posted 6 months ago #

    I want to prevent WP from messing with my url - if the user comes to http://www.mysite.com, I want it to leave the www. If they come to http://mysite.com, I don't want it to add the www.

    I am not very familiar with the backend of WP. I've seen some things that may or may not relate - but no clear solution. For example, this post here...

    They seem to have resolved it without saying how. Other posts say how to force it to always have www, or always not, but I can't find anything about just leaving it alone however it is. The stuff that I've seen about messing with MySQL tables and .htaccess is pretty much gibberish to me, so very clear instructions would be very much appreciated.

    The reason - I have a non WP page on my site that pulls in content from various places in the blog using ajax. If the user comes to http://www.mysite.com, I get a cross domain error trying to pull in from http://mysite.com/wordpress/etc. I am using relative URLs in the js, not absolute. Even if I try forcing an abosolute url that includes the www, WP strips the www and it fails.

  2. kingmoge
    Member
    Posted 6 months ago #

    Not finding any way to make wp stop this behavior, I instead made the site mimic the behavior by adding this code to the htaccess file on the root of my site. (Unfortunately I can't track down the site where I got it from to give due credit.)

    # Redirecting www version to non-www version
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    </IfModule>

Reply

You must log in to post.

About this Topic

Tags