I’m having trouble with Magento installed into a subdirectory ("magento"), which I want transparently rewritten so that the subdirectory isn’t part of the URL. First, my .htaccess:
As you can see, the first rule rewrites an empty request to the index, and the second rule should rewrite everything to include the subdirectory. The backend web configuration has store URLs set correspondingly i.e. http://domain/ rather than http://domain/magento.
With this configuration, the frontend works perfectly, with everything rewritten nicely so as not to include “/magento/”. But in the backend, all links are of the form “/index.php/” which doesn’t work - using the dashboard as an example, it should be “/admin/dashboard” (works) but instead you are redirected to “/index.php/admin/dashboard” (doesn’t work).
Does anyone have a rewrite like the above working to effectively make the document root transparently rewrite into the magento subdirectory for both the frontend and backend?
Wouldn’t it be easier to just move Magento to the root directory? I mean, I’m sure you’ve thought of that, just wondering what your reasoning is for not doing it. Seems like a lot of work
Reason for doing so is fairly simple - often you will have a domain that is primarily used for Magento, but want to host something else (blog, CMS, forum etc) on the same account/domain. This way you can keep magento and any other apps in separate directories below your document root, with the other apps accessible from /appname but with magento as the “default” application.
Someone else with what sounds like the same problem. Is it really possible that no-one else is running Magento in a subdirectory and rewriting to remove it from the URL?
I did install magento on a sub-domain. It was working fine until it was time for me to install my SSL. Turned out in order to install SSL, the domain has to be in it’s own domain. Now I have to move magento to the main directory.
If you’re planning on using SSL, my suggestion would be to just move your site to a sub-directory in the main domain. Saves you a lot of trouble.
I did install magento on a sub-domain. It was working fine until it was time for me to install my SSL. Turned out in order to install SSL, the domain has to be in it’s own domain. Now I have to move magento to the main directory.
I’m a little confused by this. If you purchase a domain-only validation certificate (which is what most people buy), you can only purchase it for one domain (e.g. http://www.domain.com, domain.com, secure.domain.com). So if you had your site running on a subdomain, you would have to purchase the SSL cert for the subdomain. HTTPS wouldn’t work on anything else unless you bought a cert for each or bought a wildcard certificate, so it would work on *.domain.com.
Please let’s keep this thread on-track, my question is nothing to do with subdomains, they will work in exactly the same way. The question is about rewriting to remove a Magento subdirectory. It doesn’t matter whether the parent is the top level of a domain, subdomain or another directory.
Haz,
your request makes perfectly sense. In fact I have the same kind of problem.
Unfortunately I don’t have the option to point my main domain on a subfolder and I want to keep the main folder clean.
I tried to use your .htacces configuration BEFORE installing magento and I have the error: Input file not specified or something along the line.
Using .htaccess after installing in the usual way, it works for the first page (home) but then all goes back to the /magento/ folder.
Maybe this might help some “expert” to find out the issue.
BTW, do you use the .htacces before or after the installation?
The version I am using is the 1.0.19870.4
in configuration > web > base url - when in Default configuration set normal http://domain/magento/ url - this will affect all areas including admin
then switch to your website or store and set http://domain/ - this will affect your store frontend
No, he has Magento installed in domain.com/subdir, and wants to access it via domain.com (no subdir). It’ll require some complex mod_rewrite rules, and seems much easier to just install it in the root directory. The organizational reason doesn’t make sense either. Install Magento in the root directory, as it’s your main application, and install everything else in sub-dirs (blog, forum, etc.).
The organizational reason doesn’t make sense either. Install Magento in the root directory, as it’s your main application, and install everything else in sub-dirs (blog, forum, etc.).
That is a bad idea. As you stick more and more unrelated directories and files in the top-level Magento directory you will lose track of what is part of the Magento application and what is not, making it difficult to manage/upgrade/backup/restore your Magento source tree. It’s really not that complicated, and is standard practice for other apps e.g. Drupal includes example rewrites in its default .htaccess.
Specifying a different DirectoryIndex alone only effectively rewrites the bare domain, every internal link will still reference the subdirectory.
Hello,
I need a solution for this problem too (sure should be plenty of people out there facing the same issue) but, as I fully support haz point, I don’t have a lot of experience with apache, and not even with magento.
My only guess is that magento might “confuse” url (as the client sees it) and physical location where the files are.
I hope that some expert on both magento and apache could come up with some solution or at least some idea where to look for the solution.
Haz, let’s keep pushing!
I had hoped that the newly added support for a custom admin URL in 1.1.1 might have meant that this would start working, but still no luck. Has anyone else found a solution yet?