Forum Moderators: phranque
What do you think the better course of action would be? Should I simply add the intro slash to all the IMG SRC occurences? Or should I add something to my .htaccess file that automatically redirects all requests for mydomain.com (without the trailing slash) to mydomain.com/ (with the trailing slash)? Any help or advice would be greatly appreciated.
Welcome to WebmasterWorld [webmasterworld.com]!
This *is* weird, because Apache mod_dir (if loaded) should add the trailing slash automatically.
First, try adding the following line to .htaccess in your web root directory:
DirectoryIndex index.html
If mod_dir is active, this may "force" it to add the trailing slash.
Second, whether that works or not, I suggest you contact your hosting service, and tell them the results of the experiment.
Third, if they are brain-locked, you can try mod_rewrite. But it should not be necessary if the server is set up correctly:
RewriteEngine on
RewriteRule ^$ http://www.yourdomain.com/ [R=301,L]
Refs: Introduction to mod_rewrite [webmasterworld.com], Apache mod_dir [httpd.apache.org], Apache mod_rewrite [httpd.apache.org]
HTH,
Jim
But I just discovered (before I read your post) that if I take all the hotlink protection stuff out of my .htaccess file that the images show up on the main page of my site in IE 6 even if the trailing slasher is not included. So, that's an easy fix, but now I won't have hotlink protection. I removed all this:
-------------
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://images.google.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.mysite.com/.*$ [NC]
RewriteCond %{HTTP_REFERER}!^http://www.google.com/.*$ [NC]
RewriteRule .*\.(jpg¦gif)$ [mysite.com...] [R,NC]
-------------
Oh, well. I guess this is okay -- I don't have too much of a problem with hotlinkers. It's not like they're going to make me exceed my bandwidth. They're just really annoying. I'll check out your ideas later today when I have the time. Much thanks!
OK, I see where you broke the images with the incorrect end-anchors. Try this instead:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.¦images\.)?google\.com [NC]
RewriteRule \.(jpg¦gif)$ - [NC,F]
Jim