Zen Cart Logo
Forums / General Questions / Cannot log in after adding www. redirect to .htaccess file

Cannot log in after adding www. redirect to .htaccess file

Views: 3,179

Results 21 to 35 of 35
18 Dec 2012, 2:46 PM
#21
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Cannot log in after adding www. redirect to .htaccess file

lhungil:

Agreed. Thus why I said the best fix was to update the define entries in the respective configure.php files. I'm sure you have seen people do some crazy things with redirects... everything from minor performance hits all the way to the point of harming their SE ranking and website. I know I have.

Lets not forget the endless loops!

Since you mentioned performance. Just plain 'common sense' should be enough to let most people know that a redirect is always going to have a negative impact on perfomance. It's the same principle as the shortest distance between two points is a straight line.. Any detour or deviation extends the route and slow the response. Ya canna disobey the laws of physics. :)

lhungil:

However my original point is having the additional redirect (setup correctly) will not cause any harm (if Zen Cart is configured correctly).

I will dispute this (simply because I can). <smiles>. I claim it can cause harm. To accept this claim though, it needs to be acknowledged a redirect or any type comes with a performance hit. This, in my opinion is 'harm' .
Now by setting a redirect that isn't needed opens up the possibility that it could be used, which is essentially the same as telling your customers, Hey, my website can be found 'here', but if you like, you can type in this other addresses instead, that will get you to the same place, albeit a little slower because the additional DNS lookups will be required and the webserver itself will need to internal modify the request to this other address.

Why would you tell your customers this less efficient way of accessing your site? it certainly doesn't do any good, and I can only see it being harmful.

lhungil:

I also wanted to point out two cases (off the top of my head) where adding a redirect related to the FQDN may have benefit (as someone asked the question). I would be remiss if I did not point out this article on the Zen Cart website currently recommends adding the redirect and gives a reason why it may be beneficial.

One of us needs to re-read that article. It starts out be stating if you've got a problem try renaming the .htaccess file so as to AVOID the issues and problems caused by redirects. Clearly, even the zen team know rewrites cause more problems than they solve.

Were you perhaps referring to:
If you are using "www." in your URL on one page and not using "www." in the URL on another page, you may have problems.

Well, yes, this is true, but this should never happen. It is bad configuration (or bad codeing), and rewriting from one to the other (or vice verci) is a means of mitigating this problem, but as I have stressed so many times before, it is the 'wrong' fix for the problem.

lhungil:

Or you may want to "help" any users who are typing your website into the address bar.

Do people still do this? I can't remember the last time typed anything in my address bar (well, perhaps a few characters, just enough to get the history expansion working. The rest of the time I'm just plain lazy (like most people, I assume) and just use the SE links after entering my search query.

lhungil:

Of course canonical links also provide this information to SEs (and are already present in current versions of Zen Cart) and help stop most SEs from considering "www.yoursite.com" and "yoursite.com" as duplicate content / separate websites.

Which is so very, very wrong. :(
"www.yoursite.com" and "yoursite.com" should be (and technically are) different sites, even if they do serve duplicate content.

lhungil:

Browsers typically do not care about duplicate URLs.

Err, mmmm, sorry, what exactly is a 'duplicate URL' again?

lhungil:

In my experience when you want to change the URL shown / linked to from a SE (I will not claim to be an expert) 301 redirects tend to be picked up faster by SEs than canonical links.

With good reason.. server response vs content parsing. 301's are designed for an instant response. Content parsing take place at a more leisurely pace so as to help avoid overload your server (The Yandex spider excepted, but that's a whole nother topic).

lhungil:

If you really want to know more I can explain the use cases in a PM. But I know you are a bright person (who is also good at debating) and can probably figure most of these out. They do not apply to the OPs problem.

Thanks for the offer to explain more, but for the most part we seem to both be on the same track (although to the casual reader it may not seem that way).
I'm pretty much nitpicking, mainly in regards to the perfomance hit that will occur with any redirect/rewrite. Oftentimes the benefits outweigh the losses, but more often than not, the gains aren't to be made, and to suggest the use of them because 'they cause no harm' isn't a compelling reason, when the harm is caused, its just that most aren't aware of it.

Cheers
Rod

ps. I've enjoyed (am enjoying) this discussion. :)

18 Dec 2012, 2:58 PM
#22
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

I have a cache folder. I had never reviewed it before so I dont really know how to evaluate it ( I will have do some research on this). However the newest file is on Dec. 11th so if I at least understand it a little, it appears that I have no errors related to this issue.

lhungil:

Some more questions... Sorry if already answered - just asking for clarification.
Can you get to the login screen in the admin?

Yes, I have always been able to get to the login page. But when I enter my username and password, and then hit enter everything clears. I dont get a wrong password message or anyhting like that. It just appears to reload the page. Right now everything is fine because I have removed all the changes I made. However, if I make the changes to the 2 configure.php files I get this problem.

lhungil:

You said after removing your changes to the .htaccess file you still cannot login to the admin?
If you remove the .htaccess file can you successfully login to the admin?
The redirects I did in the .htaccess file (the second change) worked fine. But after hearing this is the wrong way to do it, I removed those changes. However, I still have the .htaccess file with the original contents.

lhungil:

Have you tried the steps listed in this article pertaining to fixing admin login issues?
I did review this but none of this seems to be my issue. 1, 4, and 5 definitely do not apply to my situation. I checked the suggestsions on 3. And then 2 did not seem to apply since I can fix the problem by removeing the "www."'s

lhungil:

Any additional information you can provide about what may have changed on your site from when you could login to now will help the nice people here on the forums aid you.
The only other changes I made to the site are adding gift cards and adding the TPP add-on. However since I can still log-in to admin after removing my changes to the configure.php files, that does not seem to be the issue.

Thanks to everyone for responses.

18 Dec 2012, 3:05 PM
#23
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

RodG:

... (although to the casual reader it may not seem that way) ..

Also to the casual reader or newbee (thats me), this can be very confusing. There is so much information out there, including from people I am sure don't know what they are talkign about. All my free time lately has been trying to learn about all of this but it can be difficult at times.

To be honest I am stil not sure what I should do, even after this long thread.

18 Dec 2012, 5:53 PM
#24
lhungil avatar

lhungil

Totally Zenned

Join Date:
Feb 2012
Location:
mostly harmless
Posts:
1,818
Plugin Contributions:
4

Re: Cannot log in after adding www. redirect to .htaccess file

coreyalderin:

Right now everything is fine because I have removed all the changes I made. However, if I make the changes to the 2 configure.php files I get this problem.
Hmmm, today I am getting an error message in firefox "ssl_error_rx_record_too_long" when trying to access "https://toolsforchrist.com/". Do you have a SSL certificate installed for your domain? Or do you have a different path using a shared SSL certificate?

I ask because looking back - in the snippet from configure.php - HTTPS_SERVER starts with "https://"... If you are not using "https://" it needs to start with "http://" ... you will need to make sure the ENABLE_SSL_ADMIN is set to false ... and will run into other fun issues ...

18 Dec 2012, 6:05 PM
#25
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Cannot log in after adding www. redirect to .htaccess file

I've read parts of this thread intermittently since it was started. I can't comment on the entire dialog, because I've not re-read the whole thing.

But I'll offer this:

The way it works is simple:

a) your SSL certificate is issued to the www. version of your domain name.

b) your configure.php files need to include the www.

for the NON-ADMIN:
HTTP_SERVER should be your URL with the www. prefix: http://www.your_domain.com
HTTPS_SERVER should be similar, but with https ... https://www.your_domain.com
ENABLE_SSL should be set to 'true'

for the ADMIN:
(most people want to secure their entire admin, so will use the following):
HTTP_SERVER and HTTPS_SERVER should be your URL with the www. and also start with https ... so that means BOTH will be: https://www.your_domain.com
ENABLE_SSL_ADMIN would logically be set to 'true' ... although since you're defining HTTP_SERVER with an https URL, this is moot. Don't get hung up over it.

c) your .htaccess
If you're bent on making sure that every visitor who comes to your site without specifying the www. prefix, then create a simple .htaccess file in the root of your site to do the redirect.
Assuming you're not using subdomains (any other prefix besides www.) then this will probably work:```
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


d) empty your browser's cache and cookies so that it's not remembering old session stuff and thus confusing login activities.
18 Dec 2012, 6:09 PM
#26
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

lhungil:

Hmmm, today I am getting an error message in firefox "ssl_error_rx_record_too_long" when trying to access "https://toolsforchrist.com/". Do you have a SSL certificate installed for your domain? Or do you have a different path using a shared SSL certificate?

I ask because looking back - in the snippet from configure.php - HTTPS_SERVER starts with "https://"... If you are not using "https://" it needs to start with "http://" ... you will need to make sure the ENABLE_SSL_ADMIN is set to false ... and will run into other fun issues ...

I do not have SSL so that probably why you are getting that error. I do not have SSL certificate installed and I am not using a shared SSL certificate. I dont know where to edit ENABLE_SSL_ADMIN but I would imagine it is set to false because I have never had.

18 Dec 2012, 6:21 PM
#27
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Cannot log in after adding www. redirect to .htaccess file

If you don't have SSL (not sure why you wouldn't nowadays), then here's a revision from my prior post:

a) your configure.php files need to include the www.

for the NON-ADMIN:
HTTP_SERVER should be your URL with the www. prefix: http://www.your_domain.com
HTTPS_SERVER is moot. Usually would be the same as HTTP_SERVER, but say https in it. Again, moot if you don't have SSL.
ENABLE_SSL should be set to 'false'

for the ADMIN:
HTTP_SERVER should be your URL with the www. prefix: http://www.your_domain.com
HTTPS_SERVER - ignore it.
ENABLE_SSL_ADMIN would be set to 'false'. So would ENABLE_SSL_CATALOG.

b) your .htaccess
If you're bent on making sure that every visitor who comes to your site without specifying the www. prefix, then create a simple .htaccess file in the root of your site to do the redirect.
Assuming you're not using subdomains (any other prefix besides www.) then this will probably work:```
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


c) empty your browser's cache and cookies so that it's not remembering old session stuff and thus confusing login activities.
18 Dec 2012, 8:35 PM
#28
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

DrByte:

If you don't have SSL (not sure why you wouldn't nowadays), then here's a revision from my prior post:

You just gave me something to think about. I thought this was only needed for taking credit cards, but since I am using Paypal I didnt think it was necessary. Now I get it better and I am in the process of doing this right now.

But back to the main topic. I have removed all my edits to the .htaccess file so I am no longer using redirects. Changind the NON-ADMIN configure.php file works for me. But once I change the ADMIN configure.php file I can no longer log in.

18 Dec 2012, 9:12 PM
#29
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,786
Plugin Contributions:
13

Re: Cannot log in after adding www. redirect to .htaccess file

coreyalderin:

.Yes, I have always been able to get to the login page. But when I enter my username and password, and then hit enter everything clears. I dont get a wrong password message or anyhting like that. It just appears to reload the page.
Looks like real prob is blank page

18 Dec 2012, 9:30 PM
#30
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

dbltoe:

Looks like real prob is blank page

What do you mean by that?

18 Dec 2012, 10:56 PM
#31
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Cannot log in after adding www. redirect to .htaccess file

If you've decided to remove the .htaccess redirects and just letting the storefront auto-generate the www. URL, then that will probably accomplish the entire goal you set out to achieve in the first place.

Why are you making any changes to the admin side then? If it's working without any edits, then why change it? Who else needs to access it besides you? Is there a particular reason why you need to change your admin domain? If you're not using SSL, then there's nothing else that your admin domain needs to match up to, so there's no technical requirement for you to change anything.

That said, if you're really troubled by what's causing your admin login to break after you edit the admin configure.php file, then I'd be looking into things such as these FAQ articles talk about:
http://www.zen-cart.com/content.php?126-i-cant-login-to-the-admin-after-installing-zen-cart
http://www.zen-cart.com/content.php?258-i-cant-stay-logged-in-to-my-admin-area-or-php-session-handling-isnt-working-for-me

18 Dec 2012, 10:59 PM
#32
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Cannot log in after adding www. redirect to .htaccess file

dbltoe probably missed your statement that "it just appears to reload the page" and instead focused on "everything clears", since "everything clears" could easily be interpreted as "the whole page clears out and is blank, with nothing on it" ... especially since that's the most common problem encountered with any PHP script, since a fatal PHP error halts PHP execution and thus delivers no content to the page, thus resulting in a blank page.
That said, it's worth checking whether there are any PHP error/debug logs being generated, as explained here: http://www.zen-cart.com/content.php?124-blank-page

19 Dec 2012, 3:27 AM
#33
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

DrByte:

Why are you making any changes to the admin side then?

It was suggested to do so. So I thought it was important to do it. I will continue to keep it as the non-www. Thanks for all the help.

Thanks to everyone for the responses. It seems this tunred into a an extensive discussion.

19 Dec 2012, 4:31 AM
#34
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Cannot log in after adding www. redirect to .htaccess file

coreyalderin:

It was suggested to do so.
By whom, and why? What was their reasoning?

19 Dec 2012, 4:23 PM
#35
coreyalderin avatar

coreyalderin

Zen Follower

Join Date:
May 2012
Posts:
137
Plugin Contributions:
0

Re: Cannot log in after adding www. redirect to .htaccess file

DrByte:

By whom, and why? What was their reasoning?

It was suggested earlier on this thread. But no worries, its resolved now. Thanks for the help.