2017-06-20 134 views
-1

我已經創建了一個新的子域(sub.domain.com),但它一直重定向到rootdomainname(domain.com)。所以我不能編輯我的網站或登錄(Wordpress)。防止子域重定向到rootdomain

我首先假定插件WP快速緩存是問題:

# BEGIN WpFastestCache 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{HTTPS} =on 
RewriteCond %{HTTP_HOST} ^example.com 
# Start WPFC Exclude 
# End WPFC Exclude 
RewriteCond %{HTTP_HOST} ^example.com 
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WhatsApp|Mediatoolkitbot) 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{REQUEST_URI} !(\/){2}$ 
RewriteCond %{REQUEST_URI} \/$ 
RewriteCond %{QUERY_STRING} !.+ 
RewriteCond %{HTTP:Cookie} !comment_author_ 
RewriteCond %{HTTP:Cookie} !wp_woocommerce_session 
RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil 
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or] 
RewriteCond /home/username/domains/example.com/public_html/wp-content/cache/all/$1/index.html -f 
RewriteRule ^(.*) "/wp-content/cache/all/$1/index.html" [L] 
</IfModule> 
<FilesMatch "index\.(html|htm)$"> 
AddDefaultCharset UTF-8 
<ifModule mod_headers.c> 
FileETag None 
Header unset ETag 
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" 
Header set Pragma "no-cache" 
Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT" 
</ifModule> 
</FilesMatch> 
# END WpFastestCache 
# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

所以我禁用插件暫時改變htaccess文件回到基本的文件(查看是否插件是問題):

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

但它仍然重定向到根域名。

我曾嘗試在.htaccess文件中添加以下代碼沒有成功,我有.htaccess文件初學者,所以我可能把它添加到了錯誤的方式文件:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteCond %{HTTPS} !=on 
RewriteCond %{HTTP_HOST} ^example.co [NC] 
RewriteRule ^(.*)$ https://example.co/$1 [L,R=301,QSA] 

RewriteCond %{HTTP_HOST} ^(.*)\.example\.co [NC] 
RewriteRule ^(.*)/?$ http://example.co/%1/$1 [P] 
ProxyPassReverse/http://example.co/ 
</IfModule> 
# END WordPress 

能有什麼我這樣做,子域不會重定向到根域,而只是子域本身?

我已經安裝了簡單的ssl插件,但我已經嘗試了相同的插件(取消激活插件並使用此消息中的最後一個代碼)。

謝謝你的幫助!

回答

0

每次更改內容時清空瀏覽器緩存。重定向緩存了

如果您只保留.htaccess文件中的基本wordpress邏輯,它不應該重定向到基本域,除非這是您在wordpress配置中定義的域。

如果是這種情況,您需要手動編輯數據庫中的配置,或者只需從根域訪問wordpress界面(如果有效)。

0

謝謝你的迴應!

我已經設置了.htacces回:

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

有沒有加入到WP配置重定向。

因爲我無法在此子域中登錄(因爲它只重定向到根域),所以數據庫仍爲空。我確實上傳了Wordpress文件,wp-config和htaccess,但由於此重定向,我無法訪問和安裝Wordpress,因此尚無數據庫信息。