WWW/Non-WWW Path Issue

I have noticed that with my Concrete5 site, I am able to use both the www and non-www path to edit/view the website. Though, I can log into both at the sametime, almost like two different websites. I also noticed that when editing on one, that the changes I made may NOT appear on the other, unless the cache is cleared on one or the other. This seems a bit strange, and kind of an issue for me when my client is editing his website. He is also editing a parallel directory/database, so it's almost like he can log into 4 sites at once. Seems bogus.

So I was able to set up a redirect in the Web Hosting cPanel for "martyregan.com" to go to "www.martyregan.com", though it doesn't work for ANY other pages or directories throughout the site, like for example "martyregan.com/login", or "martyregan.com/jp/login". I would really like it so that my client doesn't have to worry about editing and changes not being display and him having to doing things like clear the cache every time he edits his website.

I was told by my clients web hosting service agent this exactly when I asked by the redirect only works for the homepage, and not even for the homepage for his parallel directory "www.martyregan.com/jp/":

"DNS only handles where domain would be pointing to for domain with and without www. If you need site to load only with www then you need to create proper redirect rules for which CMS default rules are creating conflict at the moment. You should have a developer properly create that for you."

It sounds like I have to do something within Concrete5, or it's database in order for this work the way I want. Maybe something with telling the .htaccess file to redirect the domain? I'm not even sure how to get to/edit it though.

Basically, I need ANYTIME "martyregan.com" is typed into the address bar, whether it'd be alone, or with an extension/directory at the end, for it to redirect to the WWW version.

Thanks ahead of time for any help I can get with this.

View Replies: View Best Answer
irsah replied on at Permalink Reply
Hi Martyregan

Have you tried an edit the your_root/config/site.php file and add this line of code;

*edit* refer below thread

You could try and see any changes in c5 pages url upon editing.

and a check on your .htaccess file to redirect your domain which will look like below;(ie apache servers);

RewriteEngine On
RewriteCond %{HTTP_HOST} ^your_domain.com$ [NC]
RewriteRule (.*) http://www.your_domain.com/$1 [R=301,L]

*edit* Ahh Hawke added some while i added the htaccess codes. thks.

martyregan replied on at Permalink Reply
Thanks! How do I access the .htaccess file? I'm a bit new to PHP databases.
mhawke replied on at Permalink Reply
FTP to the root of your site or use the File Manager in your host's Control Panel to get to the root. There should be an .htaccess file already there.
irsah replied on at Permalink Reply
Well, thru cpanel you can edit the files there. It should be in publichtml/ or publichtml/your_domain. Thru cpanel file manager (make sure checked show hidden file) an head towards the path given.

Download to your PC and edit with your fav code editor (coda - MAC, notepad - Win etc..) Add the line of codes and upload again via cpanel.

*edit* same as above

Hope it helps.
martyregan replied on at Permalink Reply
I added:
define('BASE_URL' , 'http://www.martyregan.com');

To site.php and it works like a charm for the main directory.

But now I've run into a bigger problem:
Any pages within the /jp/ directory say "Page Not Found
No page could be found at this address."
mhawke replied on at Permalink Reply
That line is no longer needed in more recent versions of C5. You should remove it.
martyregan replied on at Permalink Reply
I removed it. Though, now my /jp/ directory is broken. I don't know what went wrong. I replaced both .htaccess files with the originals, and as well as both site.php files.

But if you go to http://www.martyregan.com/jp/news/... it says the page doesn't exist. I can't go to http://www.martyregan.com/jp/login... either. I don't know what to do and my client is contacting me about this. What a nightmare.
mhawke replied on at Permalink Reply
First take a deep breath and then try this. Try turning off Pretty URLs and then turning them back on again.

This should get you to your dashboard:


and if you can't move after getting to the dashboard then these URL's might help

Clear Cache:http://www.martyregan.com/jp/index.php?cID=61...

Pretty URLs:http://www.martyregan.com/jp/index.php?cID=55...
mhawke replied on at Permalink Best Answer Reply
After you get this working again, you should consider copying your theme OUT of the '[root]/concrete/themes/' into your '[root]/themes' folder because everything under the '[root]/concrete' folder will be over-written (or ignored) when you update your site to a new version of concrete5.
martyregan replied on at Permalink Reply
mhawke, thank you very much. I am not going to lie, I actually figured it out myself before I read this thread again. I figured it out by looking at the sitemap in the /jp/ directory through the FTP. I realized there that when I saw the /index.php/ paths, so I tried them with the /jp/ directory and got back in and turned off the pretty URLs and turned them back on. I'm back in the /jp/ site! Whew. But thanks alot for the other tip...I'm going to fix that right now!

I still would like to figure out why I can't get the non-www path when typed in for the /jp/ directory to redirect to www, but I still hold off for now so I don't break anything again.

Thanks again everyone for all your help!
irsah replied on at Permalink Reply
Ahhh it seems <code>define('BASE_URL' , 'http://www.domain.com');</code> line is needed after all for 2 c5 installs in single domain, (1 in a sub-folder and one install in the root).

certain c5 versions (i think it was 5.6.++) outputs the name of the domain with non www for installs in a sub-folder, it's just grab's the domain name. (not sure why??? possible the while initiating initial setup/install i guess??)

So to create consistency on both installs you can add this code (in sub-folder c5 installs config/site.php) to have both c5 sites to output the www on web browsers.

Another approach than adding codes in .htaccess files which also depends on your server environment and availability. Something we learn day by day.

It looks great to have you site back up. All the best :-)
mhawke replied on at Permalink Reply
Best thing I've found is to handle it in the .htaccess file:

irsah replied on at Permalink Reply
Got it.. thks.