Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 5
htaccess for magento in subdirectory
 
keyur
Jr. Member
 
Total Posts:  9
Joined:  2008-09-13
 

Adding to the bottom of you original code, haz, this seems to work:

RewriteRule ^(index\.php/admin/)(.*)$ http://www.yourdomain.com/magento/admin/$2 [L,NC]

not sure why, but it only seems to work when I enter the http://www.domain.com for the substitution. it fails when I do just

/magento/admin/$2

anyone have any idea why this would be. i’m doing some other .htaccess stuff and this is just bugging me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
scorxn
Jr. Member
 
Total Posts:  16
Joined:  2008-10-20
 

Lots of overcomplication going on in this thread. Here’s what worked for me with 1.1.8:

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

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

$mageFilename 'magento/app/Mage.php';
5. Log into Magento Admin. Go to System > Configuration > Web
6. Under Unsecure change Base Link URL to http://domain.com/
7. Under Secure change Base Link URL to https://domain.com/
 
Magento Community Magento Community
Magento Community
Magento Community
 
Lorenzo66
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-06-04
London, UK
 

Brilliant explanation scorxn!!
I am going to try it soon. Thx for your work.

Lorenzo

 
Magento Community Magento Community
Magento Community
Magento Community
 
scorxn
Jr. Member
 
Total Posts:  16
Joined:  2008-10-20
 

Thanks Lorenzo. Note the recent edit. I forgot to differentiate http and https in the original post.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lorenzo66
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-06-04
London, UK
 

Hi scorxn,
Unfortunately, I had a go with lo luck.
It looks like all the media, skin, js folders can’t be rewriten correctly, i.e. they get a 404.

Lorenzo

 
Magento Community Magento Community
Magento Community
Magento Community
 
scorxn
Jr. Member
 
Total Posts:  16
Joined:  2008-10-20
 

You’re sure Base URL points to your actual installation, and Base Link URL points to your index.php and .htaccess files?

It’s a subtle but important distinction. Essentially what you’re doing is Step 1 of this tutorial:

http://www.magentocommerce.com/blog/comments/video-creating-multiple-online-storefronts-part1/

But rather than applying those settings to a new store, you’re applying them to your Default Config, thus rewriting the URLs for the entire domain.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Lorenzo66
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2008-06-04
London, UK
 

That makes tons of sense mate!!
And - not optional in this case - it works!
I guess I’m learning a bit more about it…

thx a million!!!

Lorenzo

 
Magento Community Magento Community
Magento Community
Magento Community
 
ebluewhite
Jr. Member
 
Total Posts:  17
Joined:  2008-10-06
 
scorxn - 04 December 2008 11:00 AM

Lots of overcomplication going on in this thread. Here’s what worked for me with 1.1.8:

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

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

$mageFilename 'magento/app/Mage.php';
5. Log into Magento Admin. Go to System > Configuration > Web
6. Under Unsecure change Base Link URL to http://domain.com/
7. Under Secure change Base Link URL to https://domain.com/

Thanks, Scorxn, your idea is great! It works well for me.

 
Magento Community Magento Community
Magento Community
Magento Community
 
bbodine1
Jr. Member
 
Total Posts:  6
Joined:  2009-03-29
 

Just a few things that I learned on my adventures in tackling this issue.

1. Always disable cache when working on your website. If not then things will work fine for a while after you make a change and then break later and you will have no clue what caused it to break.

2. Use CTRL + F5 to refresh your browser. This will keep your browser from using its cache and causing thing to appear ok for a while and then break later.

3. If you loose your admin control (can’t log in to admin), using PHPMyAdmin to navigate to the settings is your best option. PHPMyAdmin lets you edit your mysql database. Find the table “core_config_data”. All of the settings for the admin configuration panel are there.

4. To manually delete magento’s cache, use FTP or a filemanager to navigate to “your-magento-directory/var/cache” and delete… yes delete all the folders from mage--0 to mage--f. Don’t worry… they will come back.

I followed the instructions and found that my skin/ , media/ , and js/ directories did not point correctly. I could tell because the pages looked like a bunch of text on a white background. I added my subdirectory to the back of the base urls for these directories and it fixed everything. Example below:

Base Link URL={{unsecure_base_url}} <---did not add subdirectory
Base Skin URL={{unsecure_base_url}}magento-subdirectory/Skin/ <---did add subdirectory
Base Media URL={{unsecure_base_url}}magento-subdirectory/Media/ <---did add subdirectory
Base JavaScript URL={{unsecure_base_url}}magento-subdirectory/JS/ <---did add subdirectory

 
Magento Community Magento Community
Magento Community
Magento Community
 
unfeasible
Sr. Member
 
Avatar
Total Posts:  94
Joined:  2008-03-03
New Zealand
 

Hi, as a note/warning to others.. doing this has literally destroyed my magento install, TWICE.
(this is my second day off at work rebuilding the site)

So please be weary when doing this.

You have been warned!!

 
Magento Community Magento Community
Magento Community
Magento Community
 
michael_in_pp
Jr. Member
 
Total Posts:  11
Joined:  2008-05-27
 
scorxn - 04 December 2008 11:00 AM

Lots of overcomplication going on in this thread. Here’s what worked for me with 1.1.8:

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

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

$mageFilename 'magento/app/Mage.php';
5. Log into Magento Admin. Go to System > Configuration > Web
6. Under Unsecure change Base Link URL to http://domain.com/
7. Under Secure change Base Link URL to https://domain.com/

This with additional steps from bbodine1 works fine in version 1.3.0 too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
thesluug
Jr. Member
 
Total Posts:  3
Joined:  2008-10-29
 

Just applying the above solution resulted in none of my CSS, JS, or linked files loading.

To fix, I added the following to the htaccess file in the root folder:

RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.YOURDOMAIN.com/$1/ [R=301,L]

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

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

where MAGENTOFOLDER is the subdirectory into which you installed magento.

The last RewriteRule allows you to specify subdirectories which require direct access (i.e. no re-writing), just replace the ... with the subdirectory you need to allow direct access to.

cheers, Dave

 
Magento Community Magento Community
Magento Community
Magento Community
 
CT Schubert
Sr. Member
 
Avatar
Total Posts:  197
Joined:  2008-10-08
Southern California
 

Thanks Dave, that worked like a charm. So far, everything seems to be working perfectly…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Charles Albert
Member
 
Total Posts:  56
Joined:  2008-06-24
 

@thesluug - Hey, thanks for the informative post. I was looking after some way of directly accessing a subfolder of a magento installation, and if I understood well, the last line of that piece of .htaccess code you posted do it. Thats fine, but since my magento site is on the root of the server, I dont know what to put in the MAGENTOFOLDER place of your example. Another doubt that I have: since i just want to access directly a magento subfolder without triggering the URL rewriting, i have to use all the four lines of this block of code, or just the last line would suffice?

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Zandere
Jr. Member
 
Total Posts:  1
Joined:  2009-11-17
 

Also requested this type of feature and this seems to work pretty well for us.Thanks to all of you.

Regards

Zandere
Surendettement

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 5