2015-01-14 32 views
0

我必須託管在GoDaddy的具有下列htaccess的配置一個WordPress網站安裝的WordPress的htaccess的:如何在一個子域

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /sub-domains/shop/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

http://main-domain.com

然後我需要創建一個子域我們商店,所以我在這個文件夾中創建了一個:/ sub-domains/shop。我還安裝了另一個wordpress和woocommerce,其中永久鏈接設置爲主機名。

當我導航到http://shop.main-domain.com它呈現正常,但當我打開一個頁面例如:http://shop.main-domain.com/checkout,它重定向回到http://main-domain.com

然後,我創建一個htaccess文件:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /sub-domains/shop/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

但沒有任何反應?任何人有任何想法?謝謝。

回答

0

原來不支持我的Godaddy的窗戶,htaccess的共享主機,而不是我創建了一個Web.config文件(在子域的根文件夾)的IIS:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="wordpress" patternSyntax="Wildcard"> 
       <match url="*"/> 
        <conditions> 
         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
         <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> 
        </conditions> 
       <action type="Rewrite" url="index.php"/> 
      </rule></rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 

另外在上述託管PHP配置可以通過在子域的根文件夾中創建另一個文件php5.ini來重寫。

0

我假設htaccess文件在你的子域「shop」文件夾中?嘗試在規則的目標中移除領先斜線:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /sub-domains/shop/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . index.php [L] 
</IfModule> 
# END WordPress 
+0

嗨@Jon,是的,它在商店文件夾中。嘗試... – czetsuya

+0

仍然是一樣的錯誤:-(。它重定向到主網站。 – czetsuya

+0

@czetsuya聽起來像它可能是一個wordpress配置問題,而不是規則 –

相關問題