图像没有显示出来

时间:2014-06-30 04:40:43

标签: php regex wordpress .htaccess

我正在修建一个网站。

除非网址以www

开头,否则图片不会显示

例如,当您尝试访问此图片http://example.com/wp-content/uploads/2013/11/VictorMoreTrimed.jpg时,会将您重定向到主页。

前面有www,它会显示出来。

我尝试编辑.htaccess文件,将整个网站重定向到www版本:

    Options +FollowSymlinks 
    RewriteEngine on 
    rewritecond %{http_host} ^example.com [nc] 
    rewriterule ^(.*)$ http://www.example.com [r=301,nc] 

但它仍无效。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

由于您提供了整个htaccess,我们可以尝试在您的所有网页上插入一些行来强制www

#DirectoryIndex 
index.php 
# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 

# Insert here to force www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# End of forcing www

RewriteRule ^index\.php$ - [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress

参考:

How to force “www.” in a generic way?