Forum Moderators: phranque
now the question I have is a bit more unique... I run a server that has images for users and public viewing... the ones for users are under a password protected directory, and I was looking to see how I could get those when viewed by the public to be replaced with another default image otherwise...
in specific the following page and image (and yes this is for a porn site, so if you can't help, I can understand)
[spookygirls.com...]
should ask for a password, and when you do not have one, it should show this image
[spookygirls.com...]
but I am not sure how to do that...
now the only server issue I have is... I am on a server that I do not have direct physical access too and the root access I have might limit me to what I can do... I have access to the htdocs directory and one level higher... but that would be it...
so how do I fix this without breaking anything?
thanks!
-kristoff
Just use "mydomain.com" or "example.com" in your posted URLs, and of course, no offensive words, and it's OK.
You'll need to post more about what capabilities you *do* have to get better help. For example, if you can use mod_rewrite in .htaccess, then there are already a couple of older threads with solutions for detecting and redirecting image requests that would otherwise result in 404-Not Found errors.
Jim
Two solutions:
1) mod_rewrite
2) perl script to serve images (last post)
so what would I do to make an 404 image come up with the desired image of
[server.com...]
they had said we start with this coding:
Options +FollowSymLinks
RewriteEngine on
and where would i put this file? in the /htdocs or the directory above is as that is the only root directory access that I have...
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI}!-U
RewriteRule ^catalog_image_path/.*\.jpg$ /nonmember.jpg [L]
and that is the only thing in the .htaccess file, should there be something else?
but I got this error on the whole /htdocs directory:
The server encountered an unrecoverable error. This is usually caused by a faulty, or improperly installed CGI script or .htaccess file. If the script is written in Perl, you may wish to use this utility to check for syntax and configuration errors.
any luck?
As long as you have a space preceding the "!" in this line:
RewriteCond %{REQUEST_URI}!-U
If possible, examine your raw error log file, and see if it gives any indication of the problem. Otherwise, you may not have priveledges to use mod_rewrite after all.
You could also try a simple "test" rewrite, like
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^madeupname\.html$ /index.html [L]
Jim
the server now accepts the script... but I still cant get the graphic to come up...
^catalog_image_path/.*\.jpg$ /nonmember.jpg [L]
where would the image path be and where would the /nonmember.jpg be found? I have it in /htdocs/ but that's it...
also should I chmod it?
thanks again!
> but I still cant get the graphic to come up
Meaning what? - Do you get a broken image placeholder, or do you still see the original image?
Assuming that /htdocs is your web root directory (where your "home page" resides), the full expansion of the rewrite target URL for the image using the code above would be
http://www.yoursite.com/nonmember.jpgand the images it replaces would be in
http://www.yoursite.com/catalog_image_path/<whatever>.jpg
If you are still seeing the original images, you should flush your browser cache (delete your Temporary Internet Files). You will need to do this every time you want to test the rewrite from any machine that you've recently used to look at your site, because the original images will be cached on them, and so they will not be fetched from your server. If the images are not fetched from your server, then the rewrite can have no effect.
You may want to look into controlling the cacheability [mnot.net] of your images. Otherwise, as long as those images are cached on a given PC, they can be re-viewed whether the user is logged-in or not.
Assuming that the replacement image has the same read attributes as the original images, you shouldn't need to chmod anything.
Jim
but what I am trying to view are images only under
[mysite.com...]
(which is a password protected members only directory)
so I'm trying to get any image under that directory to be replaced with
[mysite.com...]
for anyone else that is not a member as a broken image is in it's place if you do not have a password...
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI}!-U
RewriteRule ^catalog/.*\.jpg$ /nonmember.jpg [L]
so in using that code which the server accepts (it might not read it correct, however)
what would be the proper syntaxt to direct to that directory?
Your code is correct, assuming that you still have the space before the "!".
However, it may need to be adjusted depending on where your .htaccess file resides. The code you posted would go in your web root ("home page") directory.
If you are still having trouble, you might want to try a very simple rewrite, such as
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^test\.jpg$ /nonmember.jpg [L]
Also, take a look at your raw error log. It often will give you a hint as to what is wrong. It is possible you may need to use the RewriteBase [httpd.apache.org] directive to get things working.
Jim
if the member has access and the image is 404 then the image shows up...
but if the member does not have access then the image is still broken... so I assume at this point then I'm looking to change broken 401 images instead?
xxx.xxx.xxx.xxx - - [17/Sep/2003:00:08:20 -0700] "GET /catalog/image.jpg HTTP/1.1" 401 231 "http://www.mysite.com/home.php?cat=52" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
is what shows up in my log...
The code you have so far does not comprehend user authorization. In addition, .htaccess is processed after the authorization phase, so it's not much use for custom-handling of the authorization aspect. All the code does is to serve a default image if a requested image does not exist. If that image is in your web root directory, then authorization is not taken into account.
What might be worth thinking about is this: .htaccess in a lower-level directory can override .htaccess in its parent directory. You may be able to use this to have different behaviours depending on whether the user is in a authorized directory or not.
For example, by moving the replacement image to the protected directory, then authorized users would see the replacement if they requested a non-existent image. Unauthorized users would get the password-required page. Just remember that the authorization to access files is associated with the directories and subdirectories those files reside in.
You may need to move all of this handling into your scripts in order to get it all to play nice together - the authorization-handling of the server itself is pretty primitive and inflexible. I'll think about this some today while I'm out, and post if I have any bright ideas.
Jim
I placed the .htaccess modifications in these 2 directories...
www.mysite.com
www.mysite.com/catalog
now the test.jpg image was brought up in the main directory... but the catalog directory has the password protection and after prompting for the password and incorrectly answering it, the image comes up broken... but the image comes up correct if you have the correct authentication...
so the broken image upon incorrect authorization is what I'm looking for...