2015-01-22 5 views
3

동일한 Magento 설치에서 실행되는 abc.com 및 pqr.com이라는 두 개의 웹 사이트가 있습니다. 이제는 각 Magento 디렉토리에 "blogs"폴더를 만들고 wordpress라는 두 개의 인스턴스를 blogs/abc 및 blogs/pqr 폴더에 설치 한 Wordpress를 통해 해당 도메인 각각에 대한 블로그를 만들고 싶습니다.다중 사이트에서 블로그 구성 Magento 설정

www.abc.com/blog 및 www.pqr.com/blog에 대한 요청이 blogs/abc 및 blogs/pqr 폴더로 라우팅되도록 루트 디렉토리에서 .htaccess 또는 index.php를 어떻게 구성합니까? 각기.

내 블로그 URL의 양식의 abc.com/blog이어야하고 가상 호스트 설정 (보통은/etc/아파치에 액세스 할 수있는 경우

############################################ 
## 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> 

답변

2

또한 참조 :

RewriteEngine on 

RewriteCond %{HTTP_HOST} ^(?:www\.)?(abc|pqr)\.com$ [NC] 
RewriteRule ^blog(?:/(.*))?$ /blogs/%1/$1 [NC,L] 

같은 htaccess로의 끝 부분을 재 배열하십시오
#Redirect Blogs 

RewriteCond %{HTTP_HOST} ^(?:www\.)?(abc|pqr)\.com$ [NC] 
RewriteRule ^blog(?:/(.*))?$ /blogs/%1/$1 [NC,L] 

############################################ 
## rewrite everything else to index.php 
## but never rewrite for existing files, directories and links 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 

RewriteRule .* index.php [L] 

RewriteCond와 바로 다음 RewriteRule는 리디렉션 규칙을 형성하기 위해 함께 모여 있습니다. 당신은 그 기능을 해치는 블로그 관련 규칙을 끼워 넣었습니다.

+0

이 코드를 ################## 바로 위에 쓸 때 ################### ## ## 다른 모든 것을 index.php에 다시 작성하십시오. RewriteRule. * index.php [L] - http : //www/example.com에 http://www.example.com/blog/redirects를 요청합니다. = abc. – SarthakGupta

+0

귀하의 규칙을 더 잘 이해할 수 있도록 질문에 현재 htaccess를 게시하십시오. –

+0

내 .htaccess에서 리디렉션 섹션을 추가했습니다. – SarthakGupta

1

을 blog.abc.com하지 싶지 있습니다/sites-enabled/abc)을 입력하면 abc.com의 가상 호스트에 대한 가상 호스트와 pqr.com의 가상 호스트에 대한 유사 콘텐츠 만 입력하면

Alias /blog /var/www/blogs/abc 

을 입력하면됩니다.

또한 mod_alias를 활성화해야합니다. 이것은 htaccess로 파일에서 수행 할 수 없습니다, 루트의 .htaccess에 다음을 추가 this document

+0

나는/var/www/vhosts/abc/conf /에 vhost.conf를 만들고 위에서 언급 한 줄만 입력했습니다. 서버를 다시 시작해야합니까? – SarthakGupta