Magento Redirect base url

2019-07-31 06:13发布

问题:

I have all my folders and files in www.mysite.com/magento/ and my home page base url is www.mysite.com/magento/. I need to change this url to only www.mysite.com and if possible I don't wanna move my files from /magento/ to the back folder.

If I use System - Configuration - Web from my magento-admin-panel, it doesn't work and I can't connect to panel.

回答1:

You should be able to accomplish that using .htaccess and RewriteBase.

Here's commented out example in Magento .htaccess sample:

############################################
## you can put here your magento root folder
## path relative to web root

RewriteBase /magento/

That should do the trick in your case.

You can read more about RewriteBase here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#page-header

Edit: In the web root, you'll need some sort of rewrite to Magento root directory:

RewriteEngine on
RewriteCond %{REQUEST_URI} !magento/
RewriteRule (.*) /magento/$1 [L]

Keep in mind that there are all just untested examples that should point you in the right direction. :)

Cheers.