Resolving Magento Admin Inaccessibility Due to URL Rewriting
When you have Magento installed in a subdirectory of your root directory, enabling secure pages can sometimes cause the admin panel to become inaccessible. This issue arises when the configured base URLs for the frontend and backend are not set correctly or do not match your SSL configuration.
Understanding the Issue
In your case, you’ve correctly configured the frontend to rewrite URLs using the RewriteBase directive in the root .htaccess. This ensures that URLs like http://mydomain.com/shop/ are rewritten as http://mydomain.com/.
However, when it comes to the admin panel access, Magento needs a specific URL structure to recognize and process requests correctly. The default admin URL format is {base_url}/index.php/admin/. If this path is not properly configured or rewritten, Magento cannot locate the admin entry point.
Analyzing Your Current Configuration
You’ve provided your current .htaccess files for both the root directory and the Magento shop folder (subdirectory). Let’s break down the relevant sections:
- Root Directory .htaccess
The RewriteEngine On directive enables URL rewriting in Apache. The RewriteBase / directive specifies that all rewritten URLs are relative to the web root.
- Magento Shop Folder (.htaccess)
This file contains the standard Magento .htaccess configuration needed for proper functioning of the application, including setting memory limits, disabling magic quotes, and enabling compression with mod_deflate.
Resolving the Admin Access Issue
To resolve this issue, you need to ensure that your admin URL is properly rewritten and matches the configured base_url in your Magento configuration file (app/etc/local.xml).
Step 1: Check Your Base URLs Configuration
Open your local.xml file located in the app/etc/ directory of your Magento installation. Look for the <url> node and verify that your secure base URLs are correctly set.
<url>
<base url="http://mydomain.com/shop/" />
<secure_base url="https://mydomain.sharedssl.com/shop/" />
</url>
Step 2: Update Your Root Directory .htaccess
In the root directory .htaccess file, update your RewriteBase directive to point to the Magento subdirectory where you have installed the application.
Replace this line:
RewriteBase /
With:
RewriteBase /shop/
Step 3: Update Your Admin URL Configuration
If your admin path is not set correctly, update it in the admin node of your local.xml file.
<admin>
<routers>
<adminhtml>
<args>
<frontName>admin</frontName>
<use_session_in_url>1</use_session_in_url>
<layout_handles>
<login handle="adminhtml_login_layout"/>
<logout handle="adminhtml_logout_layout"/>
<default handle="adminhtml_default_layout"/>
</layout_handles>
</args>
</adminhtml>
</routers>
</admin>
Ensure that the frontName attribute is set to admin, and update it if necessary.
Conclusion
Resolving Magento admin accessibility issues due to URL rewriting involves a careful examination of your base URLs configuration in the local.xml file, as well as updating your .htaccess files accordingly. Properly configuring the RewriteBase directive in the root directory and ensuring that your admin path matches your SSL configuration are crucial for maintaining access to both the frontend and backend of your Magento store.
Remember to always backup your files before making any changes, and test your configurations thoroughly after each update to ensure proper functionality. If you’re still experiencing issues or need further assistance with Magento URL rewriting, feel free to explore the comprehensive guides available at Laravel Company.
Happy coding!