2014-03-06 41 views
0

我有網站由wordpress開發,我面臨的問題是圖像不與URL協調。Wordpress從圖像中刪除'www'url

圖像URL應該是...

http://domainname.com/wp-content/uploads/2012/09/handshake-cropped-300x2651.png 

,但我用「WWW」,即獲得:

http://www.domainname.com/wp-content/uploads/2012/09/handshake-cropped-300x2651.png 

這樣的原因圖像不加載到我的網站,我在媒體庫檢查爲圖片網址...

這個問題的原因是什麼?我該如何解決這個問題。即使我有改變上傳路徑網址和網站網址太:(

+0

可以將其幫你加這個代碼/wordpress.stackexchange.com/questions/33724/remove-links-from-images-using-functions-php – hizbul25

+0

從網址ya中刪除www僅用於圖片網址 –

+0

only image url @ ravipatel – Aaru

回答

0
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L] 

OR

# force non-www domain 
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] 
RewriteRule (.*) http://example.com/$1 [R=301,L] 
0

您可以創建在您的DNS映射的WWW域名主域名CNAME記錄。轉到您的DNS管理器並添加一個WWW。記錄指向@或域IP

你還需要在你的Apache配置添加一個別名。

ServerAdmin [email protected] 
ServerName example.com 
ServerAlias www.example.com 
0

這裏有改進的範圍。但讓我知道這是否有效。 [刪除在WordPress的圖片URL] [1] [1]:HTTP:/

add_filter('the_content', 'attachment_image_link_remove_filter'); 

function attachment_image_link_remove_filter($html) { 
    return str_replace('<img src="http://www.','<img src="http://',$html); 
} 


add_filter('post_thumbnail_html', 'my_post_image_html', 10, 3); 

function my_post_image_html($html, $post_id, $post_image_id) { 
    return str_replace('http://www.','http://',$html); 
} 

到functions.php