1

I am working on fixing a website.

Images don't show up unless the url starts with www

For example when you try to access this image http://example.com/wp-content/uploads/2013/11/VictorMoreTrimed.jpg, it redirects you to the home page.

With the www in front, it shows up.

I tried to edit the .htaccess file to redirect the whole website to the www version:

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

But it still not working.

Can anyone help please ?

Deleted User
  • 2,507
  • 1
  • 9
  • 18
user00239123
  • 242
  • 3
  • 16
  • Happy to look at it, Mahmoud. But would highly recommend changing your links to `example.com` for two reasons: first, many people will worry about clicking an unknown link (which might capture their location etc); second, a moderator may look at the links as spam. – zx81 Jun 30 '14 at 04:50

1 Answers1

1

Since you provided your entire htaccess, we can try inserting some lines to force www on all your pages.

#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

Reference:

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

Community
  • 1
  • 1
zx81
  • 38,175
  • 8
  • 76
  • 97
  • Hi zx81 , thank you . but unfortunately I tried it and it did not work .Maybe there is a delay or something ? – user00239123 Jun 30 '14 at 05:04
  • Is there anything else in your htaccess? It sounds like there is a rule somewhere that redirects to the home page in certain conditions. Or are there rules somewhere in other code? – zx81 Jun 30 '14 at 05:11
  • Well , this is the other code in my htaccess file #DirectoryIndex index.php # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress it's WordPress common code – user00239123 Jun 30 '14 at 05:12
  • Thanks for providing your htaccess. Please see my updated answer. – zx81 Jun 30 '14 at 05:17
  • Thank you . Your code works , but not with the images on the homepage !! This is weird ! – user00239123 Jun 30 '14 at 05:27
  • for example it **works with this one http://vivahealthylife.com/wp-content/uploads/2013/11/BookAppointmentOnLine.jpg ** but **not with this one http://vivahealthylife.com/wp-content/uploads/2013/11/VictorMoreTrimed.jpg ** – user00239123 Jun 30 '14 at 05:33
  • Are you able to check on your server if the file name is capitalized exactly that way? We seem to be hitting the `!-f ` condition. – zx81 Jun 30 '14 at 05:39
  • I think it was my browser cache or a delay . Everything works great now , thank you – user00239123 Jun 30 '14 at 06:22
  • Terrific. Thank you, see you next time. :) – zx81 Jun 30 '14 at 06:22
  • It was pleasure to communicate with you . Thank you very much , I hope to meet you again – user00239123 Jun 30 '14 at 06:25
  • Likewise, Mahmoud... See you next time! :) – zx81 Jun 30 '14 at 06:27