[Solved] Magento: Login Redirect to Home Page, even if remove var/cache
Update:
This paeg also solved my problem: http://www.aschroder.com/2009/05/fixing-magento-login-problem-after-a-fresh-installation/
Situation:
I download a copy of magento from production server to local machine (Win 7 + XAMPP 1.8.2) and try to set it up.
After setting it up and load the home page (index.php), it redirected me to the old, production URL.
Problem:
However, there are times when it still did not work (still redirect to index.php when go to admin/), even you have already remove/delete the var/ folder, which contains cache/ and sessions/.
So how to solve this problem?
Solution:
URL redirection is not only controlled by setting in DB, but also it is controlled by mod_rewrite/.htaccess.
This is my .htaccess:
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
############################################
## uncomment next line to enable light API calls processing
# RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
############################################
## rewrite API2 calls to api.php (by now it is REST only)
RewriteRule ^api/rest api.php?type=rest [QSA,L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## redirect for mobile user agents
#RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
#RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
#RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
RewriteCond %{REQUEST_URI} ^/(index.php/)?admin/ [OR]
#RewriteCond %{REQUEST_URI} ^/(index.php/)?admin/ [NC,OR]
RewriteCond %{REQUEST_URI} ^/downloader/ [OR]
#RewriteCond %{REQUEST_URI} ^/cms/ [NC]
RewriteCond %{REQUEST_URI} ^/cms/wp-admin/ [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/ [R=302,L]
</IfModule>
As you can see, the problem is on the last one. All you need to do is to comment it out (add a # before this line), and you should be fine.
Now comment it and go to your magento admin panel to see if it works.
Hope it helps someone.
This takes me 1/2 day to figure it out.
Comments