homepage Welcome to WebmasterWorld Guest from 54.204.68.109
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Rewrite not working in root directory
But it's working in sub directories. Where's my error?
kenta




msg:1509851
 3:23 am on Sep 12, 2002 (gmt 0)

I've been working on this and I can't seem to figure out why it's not working correctly.

I have the following in a .htaccess file in a directory, let's say it's in "/home/foo/public_html/pictures". It works, the pictures are changed to show the "noaccess.gif" file.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?some.site.org/.*$ [NC]
RewriteRule \.(gif¦jpg)$ [some.site.org...] [R,L]

When I move the code to the top level .htaccess file (which we'll say is in "/home/foo/public_html/". The code DOES prevent the images from showing up from anywhere on the site, but wont display noaccess.gif.

Odd. Ideas?

[edited by: DaveAtIFG at 5:33 am (utc) on Sep. 13, 2002]
[edit reason] URLs "revised" [/edit]

 

jdMorgan




msg:1509852
 4:21 am on Sep 12, 2002 (gmt 0)

kenta,

Very strange! Your rewrite directives look correct, although there are a few extra characters that aren't needed (e.g ".*$" - cleaned up below). Do you have the Options directive in your top-level .htaccess? Are there any rewrite rules in the top-level .htaccess that are not present in the subdirectory version? These other rewrite rules, if they precede the ones you are having trouble with, might be interfering with your intended results.

Since I don't see anything wrong with what you posted, I'll try to make this post worthwhile by pointing out a few more lines you might want to add. These additions will allow your site to be properly displayed by various search engines that offer cached versions of your pages and/or language translation service. They cache the html page, but they don't cache the images. So, unless you let the user access the images with a modified referer, your images will show as broken image links in the cached page.

The additions will allow Google, AltaVista, Gigablast, and Comet Systems translators and caches to display your images.

Options +FollowSymlinks -Indexes
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?some.site.org [NC]
RewriteCond %{HTTP_REFERER} !^http://216\.239\.(3[2-9]¦[4-5][0-9]¦6[0-3])\..*(www\.)?some.site.org [NC]
RewriteCond %{HTTP_REFERER} !^http://babel.altavista.com/.*(www\.)?some.site.org [NC]
RewriteCond %{HTTP_REFERER} !^http://216\.243\.113\.1/cgi/
RewriteCond %{HTTP_REFERER} !^http://search.*\.cometsystems\.com/search.*(www\.)?some.site.org [NC]
RewriteRule \.(gif¦jpg)$ [some.site.org...] [R,L]

If you still can't get it to work after adding the Options directive, feel free to stickymail me your entire top-level .htaccess file - I'd be happy to take a look.

Note: You may or may not want the "-Indexes" option. The one that might matter here is the "+FollowSymlinks" option.

Jim

[edited by: DaveAtIFG at 5:34 am (utc) on Sep. 13, 2002]
[edit reason] URLs "revised" [/edit]

kenta




msg:1509853
 3:26 am on Sep 13, 2002 (gmt 0)
Thanks for the additional info. Ends up I added the "Options +FollowSymlinks" and it didn't make a difference. The "noaccess.gif" still didn't show.

Tried copying your code and ended up with the same results. Prevents the image, but not my custom .gif.

As far as the file, it just has:

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName AllowLocalAccess
AuthType Basic

order deny,allow
deny from (IP HERE)

About half a dozen deny's and then that code. I tried stripping the entire .htaccess file and it didn't make a difference.

I spent a little time looking for something that might make a difference in my http.conf, but so far nothing conclusive.

jdMorgan




msg:1509854
 3:52 am on Sep 13, 2002 (gmt 0)

kenta,

Check out post numbers 82 & 83 here [webmasterworld.com].

Maybe you need AllowOverride Options enabled?

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved