Zen Cart Logo
Forums / General Questions / Htaccess effecting admin login, not sure why?

Htaccess effecting admin login, not sure why?

Views: 1,015

Results 1 to 8 of 8
13 Jun 2011, 8:27 AM
#1
bottyz avatar

bottyz

New Zenner

Join Date:
Mar 2010
Location:
Nottingham UK
Posts:
90
Plugin Contributions:
0

Htaccess effecting admin login, not sure why?

Hi all,

I want to implement a non-www to www script in my htaccess as follows:

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

If I put that in my htaccess everything works great except my admin login. When I enter the username and password it just reverts back to the same login page.

I've read other posts and checked that both configure.php files have the following:

Admin:

define('HTTP_SERVER', 'http://www.mydomain.com');
define('HTTPS_SERVER', 'https://www.mydomain.com');
define('HTTP_CATALOG_SERVER', 'http://www.mydomain.com');
define('HTTPS_CATALOG_SERVER', 'https://www.mydomain.com');

Catalog:

define('HTTP_SERVER', 'http://www.mydomain.com');
define('HTTPS_SERVER', 'https://www.mydomain.com');

All with the www. But the problem still exists... Any ideas?

13 Jun 2011, 8:43 AM
#2
bottyz avatar

bottyz

New Zenner

Join Date:
Mar 2010
Location:
Nottingham UK
Posts:
90
Plugin Contributions:
0

Re: Htaccess effecting admin login, not sure why?

Hi all,

Just tried another browser, and it works. My Firefox 4 still just redirects randomly? I've cleared cache, etc... Might just have to re-install and try again. Unless it is a browser bug?

So problem solved. Thanks for looking.

17 Jun 2011, 9:54 PM
#3
tech_no_babble avatar

tech_no_babble

New Zenner

Join Date:
Aug 2010
Location:
21115 Glendale Ave Port Charlotte FL 33952
Posts:
17
Plugin Contributions:
0

Re: Htaccess effecting admin login, not sure why?

I just came across this same issue. I was not able to access the site after creating the htaccess file days ago. I called the owner of the site and neither worker there could access the admin section. I had tried multiple browsers and PCs in the office to log in. I even reset the password using the SQL trick.

Nothing worked until I renamed the .htaccess file. This is the same file I have used for other sites, but not zen cart sites. The only addition to the .htaccess file I have added was redirect 301 /index.htm http://www.mydomian.com/shop.

Does anyone know how to redirect non-www to www with zen cart?

Thanks,

Alex

18 Jun 2011, 4:37 AM
#4
drbyte avatar

drbyte

Sensei

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

Re: Htaccess effecting admin login, not sure why?

Tech NO Babble:

I just came across this same issue. I was not able to access the site after creating the htaccess file days ago. I called the owner of the site and neither worker there could access the admin section.

Does anyone know how to redirect non-www to www with zen cart?
More importantly, WHY are you finding this to be necessary?

If your admin is set up to use a www. URL then it WILL do that automatically. You DO NOT need any redirects to make that happen. Just configure it (in the aptly named configure.php files) with the appropriate URL.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Jun 2011, 5:45 PM
#5
tech_no_babble avatar

tech_no_babble

New Zenner

Join Date:
Aug 2010
Location:
21115 Glendale Ave Port Charlotte FL 33952
Posts:
17
Plugin Contributions:
0

Re: Htaccess effecting admin login, not sure why?

As I understand, if you don't do a http to www redirect, then https://www.yoursite.com and http://www.yoursite.com are considered 2 different sites. I have been added the htaccess to root of my sites for years. I haven't heard any different from Google on this, so its standard operating procedure for our company to add this htaccess file to our clients websites.

20 Jun 2011, 2:50 AM
#6
drbyte avatar

drbyte

Sensei

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

Re: Htaccess effecting admin login, not sure why?

Regardless, I still don't understand why you're trying to use RewriteRules to redirect your admin to a www. URL.

a) if it's important to you that the www. version of the site be the primary version, then it would seem logical to me that you'd configure the store as such, in the ONLY place in Zen Cart where the URL is set: in the configure.php files.

b) any attempt to access your admin, without first being logged in, will automatically redirect you to the URL set in the configure.php file, thus causing you to never need to use RewriteRules to muss with your admin URL

c) why are you trying to get Google to index your admin?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

23 Jun 2011, 9:23 PM
#7
tech_no_babble avatar

tech_no_babble

New Zenner

Join Date:
Aug 2010
Location:
21115 Glendale Ave Port Charlotte FL 33952
Posts:
17
Plugin Contributions:
0

Re: Htaccess effecting admin login, not sure why?

DrByte,

Thanks for helping. I believe I need to clarify what I am trying to do. I am not trying to redirect the admin section of any of my client's sites that are using Zen Cart.

All websites that we create or use software like WordPress for our clients have a .htaccess file that redirects http to www. This file is added to (on a cPanel server) the public_html file. The Zen Cart stores are usually set in their own folder (store, shop).

So:
a. not redirecting the admin .htaccess file looks like this: ```
RewriteEngine On
RewriteCond %{HTTP_HOST} ^site.com
RewriteRule (.*) http://www.site.com/$1 [R=301,L]


b. I see where you are going, but that is not my intention.

c. Again, only interested in having the site index by search engines for www and non-www as the same site, not separately.

Sorry if I am confusing, until this happened this has been SOP for us Marketing our sites. If you go to [http://websitegrader.com](http://websitegrader.com) and check on a site with no www/non-www canonical redirect, you will be told that you should add one.

Thanks for following this thread and I appreciate the help for this awesome product.

Alex
23 Jun 2011, 10:14 PM
#8
dbltoe avatar

dbltoe

Totally Zenned

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

Re: Htaccess effecting admin login, not sure why?

I believe what you are actually trying is having non-www and www go to just one place to avoid possible duplicate content flags.

IF that's what you are wanting to do and you are on a Linux box...> RewriteEngine On

RewriteCond %{HTTP_HOST} ^site.com
RewriteRule (.*) http://www.site.com/$1 [R=301,L]Might need to be something like> RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.site.com$
RewriteRule ^/?$ "http://site.com" [R=301,L]Of course, we take ours from www to non-www so you will need to adjust accordingly.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com