【发布时间】:2015-03-20 21:21:19
【问题描述】:
我有两个网站说 abc.com 和 pqr.com 从同一个 Magento 安装运行。现在我想通过 wordpress 为每个域创建博客,为此我在 Magento 根目录中创建了一个文件夹“blogs”,并在名为 blogs/abc 和 blogs/pqr 的文件夹中安装了两个 wordpress 实例。
如何在根目录中配置我的 .htaccess 或 index.php,以便将对 www.abc.com/blog 和 www.pqr.com/blog 的请求分别路由到文件夹 blogs/abc 和 blogs/pqr .
请注意,我希望我的博客 URL 的格式为 abc.com/blog 而不是 blog.abc.com
############################################
## you can put here your magento root folder
## path relative to web root
RewriteBase /
############################################
## uncomment next line to enable light API calls processing
# RewriteRule ^api/([a-z][0-9a-z_]+)/?$ api.php?type=$1 [QSA,L]
############################################
## rewrite API2 calls to api.php (by now it is REST only)
RewriteRule ^api/rest api.php?type=rest [QSA,L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks
RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]
############################################
## redirect for mobile user agents
#RewriteCond %{REQUEST_URI} !^/mobiledirectoryhere/.*$
#RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
#RewriteRule ^(.*)$ /mobiledirectoryhere/ [L,R=302]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
#Redirect Blogs
#RewriteCond %{HTTP_HOST} ^(?:www\.)?(abc|pqr)\.com$ [NC]
#RewriteRule ^blog(?:/(.*))?$ /blogs/%1/$1 [NC,L]
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
【问题讨论】:
标签: apache .htaccess rewrite server