PDA

View Full Version : Magento , SSL, subdirectory, .htaccess



ascrivner
04-25-2011, 01:21 PM
Hi All,

I needed an SSL cert for a Magento webstore that existed as a subdomain of my primary domain.

To get the SSL cert just for my subdomain, I had to change my subdomain into my primary domain, so I had bluehost make the change.

Since magento was still in a subdir ( public_html/webstoredomain ), the public_html/.htaccess was all messed up and I could only see the homepage of the magento store.

The directions that bluehost give as a .htaccess solution to the subdir issue DO NOT WORK FOR A MAGENTO SITE.

Here is the solution to get a Magento site working from a subdir if you have to get an SSL cert and have move a subdomain to a primary:

Givens (Substitute as necessary)
a. /public_html/ is your root web directory
b. /public_html/webstoredomain/ is where you want to store Magento
c. webstoredomain.com is your domain name

Steps
1. Install Magento to /public_html/webstoredomain/ normally. Do not change Base URL during installation.
2. Copy /public_html/webstoredomain/.htaccess to /public_html/.htaccess
3. Copy /public_html/webstoredomain/index.php to /public_html/index.php
4. Edit /public_html/index.php line 45 for Magento 1.5.1 to read:

$mageFilename = 'webstoredomain/app/Mage.php';

5. Log into Magento Admin. Go to System > Configuration > Web
6. Under Unsecure change Base Link URL to http://webstoredomain.com/
7. Under Secure change Base Link URL to https://webstoredomain.com/


Now everything should work.

ascrivner
04-27-2011, 12:55 PM
I just wanted to add some more to this:

The .htaccess for a magento store served from /public_html but residing in a subdir in public_html/webstoredomain


# Begin .htaccess
# www.webstoredomain.com with magento installed in public_html/webstoredomain


RewriteEngine on
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php

#Force all traffic to HTTPS
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

#Begin rules for subdir rewrites
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.WEBSTOREDOMAIN.com/$1/ [R=301,L]

RewriteCond %{http_host} ^WEBSTOREDOMAIN\.com [NC]
RewriteRule ^(.*) http://www.WEBSTOREDOMAIN.com/$1 [R=301,L,NC]

RewriteRule ^$ /WEBSTOREDOMAIN/ [QSA,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !^(WEBSTOREDOMAIN|...|...|subdirN)(/.*)?$ /WEBSTOREDOMAIN%{REQUEST_URI} [QSA,L]

ascrivner
04-27-2011, 01:02 PM
Please try using my .htaccess file fix to resolve this issue before going this route, I posted this before I fixed the real issue, and this while it works, it not as clean as just getting the correct .htaccess in place.



Hi All,

I needed an SSL cert for a Magento webstore that existed as a subdomain of my primary domain.

To get the SSL cert just for my subdomain, I had to change my subdomain into my primary domain, so I had bluehost make the change.

Since magento was still in a subdir ( public_html/webstoredomain ), the public_html/.htaccess was all messed up and I could only see the homepage of the magento store.

The directions that bluehost give as a .htaccess solution to the subdir issue DO NOT WORK FOR A MAGENTO SITE.

Here is the solution to get a Magento site working from a subdir if you have to get an SSL cert and have move a subdomain to a primary:

Givens (Substitute as necessary)
a. /public_html/ is your root web directory
b. /public_html/webstoredomain/ is where you want to store Magento
c. webstoredomain.com is your domain name

Steps
1. Install Magento to /public_html/webstoredomain/ normally. Do not change Base URL during installation.
2. Copy /public_html/webstoredomain/.htaccess to /public_html/.htaccess
3. Copy /public_html/webstoredomain/index.php to /public_html/index.php
4. Edit /public_html/index.php line 45 for Magento 1.5.1 to read:

$mageFilename = 'webstoredomain/app/Mage.php';

5. Log into Magento Admin. Go to System > Configuration > Web
6. Under Unsecure change Base Link URL to http://webstoredomain.com/
7. Under Secure change Base Link URL to https://webstoredomain.com/


Now everything should work.

breschcr
07-21-2011, 04:01 PM
I know this post was from awhile ago, but I'm having a similar issue.
-I've got a wordpress installation at /public_html/ (this is my primary domain)
-I've got my magento installation at /public_html/magento

I have no trouble viewing, using or seeing both sites. What I'm unable to do is utilize the SSL or HTTPS connection when using the magento site.

I've enabled the options in Magento > Configuration > Web > Secure to utilize a secure URL's in Frontend and Admin
Unfortunately, I'm not seeing the results. The secure link doesn't render in the browser.

I'm wondering if your solution is an appropriate fix?
And if so, do I utilize the solution at the top (copying .htaccess files to root directory?)

Please help!
Thanks in advance!

Best,
-Noob