solved Media Pro Skin WWW issue

MySong
MySong
@mysong
10 years ago
155 posts
When site is accessed as http://site.com - all is well

but when site is accessed as http://www.site.com - then 'top singles', 'newest Artists' and 'top 10 Artists' on Home page do not load. Continuously says "Loading..."

Tested in FF, Chrome and Internet Explore.

See same issue on 'showcase site' http://www.indiemusician.org which also seems to be using Media Pro Skin.

Main issue with this is that most external links to sites contain "WWW" in url.
updated by @mysong: 10/30/14 02:14:38PM
brian
@brian
10 years ago
10,144 posts
This isn't a skin issue, this is because your .htaccess is not setup to redirect the user to your URL WITH www. When anything loads via an AJAX call, the browser checks the originating domain and ensures they match, and "http://www.site.com" and "http://site.com" are seen as 2 different domains to the browser (and for browser security, it will not load content cross domain without proper CORS setup).

The fix is that you need to add some rules to your Jamroom .htaccess file, and based on your post it looks like your Jamroom URL is set to use "www". So that means if anyone requests a URL from your site that does NOT begin with www, the .htaccess rules need to redirect.

So add this to your .htaccess:

# HTTP
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule .? http://www.site.com%{REQUEST_URI} [R=301,L]

# HTTPS
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule .? https://www.site.com%{REQUEST_URI} [R=301,L]

Of course replace "site.com" with your domain.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MySong
MySong
@mysong
10 years ago
155 posts
Just want to make sure I got this right...

1 - JR can only load in either the WWW version or the base domain version. It can not work correctly on both and the solution is only to redirect either one at the other.

2 - Deciding whether JR will run on WWW or on base domain is done in the
data > config > config.php file.

3 - Will changing the setting from base domain to WWW on an active site in config.php, will that cause any disturbances on site or is it a smooth transfer with no other modifications needed?

4 - Assuming site is running on a WWW version (after changed in config.php) what would be the proper version of the above code listed above for the .htaccess ,if that is even needed at all.

Thanks,
michael
@michael
10 years ago
7,697 posts
Its a javascript issue. Javascript is built so that you cant access a different sites stuff.

javascript views www.site.com as one site and site.com as a completely different site. in the same way aaaaa.com is different to bbbbb.com.

If your on aaaaa.com and say "Javascript load bbbbb.com/some-page into my div on aaaaa.com" javascript will say "Nope.".

So you have to choose between www.your-site.com and your-site.com.

The .htaccess stuff brian has above is how to make that choice.
MySong
MySong
@mysong
10 years ago
155 posts
Site is currently on the Non-WWW version.
Trying to put site on the WWW version and then after that redirect all site.com to www.site.com using @brian code above or @SteveX code on https://www.jamroom.net/ultrajam/documentation/code/1433/htaccess-tips

However when I go into data > config > config.php file and update it to $_conf['jrCore_base_url'] = 'http://www.site.com';
I can no longer log into the site both on
http://www.site.com/user/login
and http://site.com/user/login
I get the following error message "a system level error was encountered trying to validate the form values: error:"
douglas
@douglas
10 years ago
2,774 posts
After changing your config.php file, did you delete the files in your data/cache/jrMediaPro and data/cache/jrCore folders?


--

Douglas Hackney
Jamroom Team - Designer/Developer/Support
FAQ-Docs-Help Videos
MySong
MySong
@mysong
10 years ago
155 posts
Tried deleting them both via FTP and hosting C-panel but after a few min they come right back. Regardless it still does not allow me to login to admin account, giving same error message.

Any idea?

Thanks,
MySong
MySong
@mysong
10 years ago
155 posts
Cleared browser cache and now it is working. Let me test more before anyone spends any time on this.
MySong
MySong
@mysong
10 years ago
155 posts
Switching the site to the WWW version, now seems to be working, seems it was a cache issue both from browser and site.

Now up to step 2 of redirecting all site.com pages to their WWW version.

I added the code given above by @brian to the .htaccess

On home page it works fine; when site.com is entered in browser, it redirects to www.site.com

Issue is with sub pages. Lets say I enter the following page into browser
http://site.com/john-doe/audio/albums/song-one
instead of redirecting to http://www.site.com/john-doe/audio/albums/song-one
it redirects to
http://www.site.com/modules/jrCore/router.php?_uri=john-doe/audio/albums/song-one
and gives "NOT FOUND The page you requested was not found!" error message.
MySong
MySong
@mysong
10 years ago
155 posts
Here are the entire contents of the .htaccess (domain name changed)

# Jamroom 5 Apache .htaccess file
DirectoryIndex index.html index.php sitemap.xml modules/jrCore/router.php

Options +FollowSymLinks
Options -MultiViews -Indexes

# Use ETags

Header unset ETag
FileETag None
# Expires for CSS, JS and Images

Header set Expires "Thu, 15 Apr 2018 20:00:00 GMT"



# Compress everything we can

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript text/javascript-x application/javascript


# All requests through the router

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ modules/jrCore/router.php?_uri=$1 [NC,L]


# HTTP
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule .? http://www.site.com%{REQUEST_URI} [R=301,L]
brian
@brian
10 years ago
10,144 posts
We use basically the same exact setup here on jamroom.net and I'm not seeing any problems. Note that we support both http and https here, so our rewrite section looks like:

# HTTP
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^jamroom\.net [NC]
RewriteRule .? http://www.jamroom.net%{REQUEST_URI} [R=301,L]

# HTTPS
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^jamroom\.net [NC]
RewriteRule .? https://www.jamroom.net%{REQUEST_URI} [R=301,L]

Note that this should be ABOVE the other rewrite conditions - change yours to:

RewriteEngine On

# HTTP
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} ^site\.com [NC]
RewriteRule .? http://www.site.com%{REQUEST_URI} [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ modules/jrCore/router.php?_uri=$1 [NC,L]

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MySong
MySong
@mysong
10 years ago
155 posts
Works :)

Thanks for the help.
brian
@brian
10 years ago
10,144 posts
MySong:
Works :)

Thanks for the help.

Glad to hear it - thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
MySong
MySong
@mysong
10 years ago
155 posts
Just a note to anyone converting their site to WWW or the other way around...

Do not forget to update the url of the site hook on foxycart.com in order for JRfoxycart to continue working.