Forum Moderators: phranque
======================================
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://www.MY-DOMAIN.com/(.*)$ [NC]
RewriteCond %{REQUEST_FILENAME}!^(.*)Start-UP.htm(.*)$ [NC]
RewriteRule \.(htm¦html¦gif¦jpg¦doc)$ [MY-DOMAIN.com...]
========================================
I have two Q for you :)
1. I have files that have no any file extension
[data1] [data2] etc
how do I include these in rewriteRule
2. if I want to apply all file type in RewriteRule
How do I do it?
This list is too long. (htm¦html¦gif¦jpg¦doc png txt)
Thanks for your kind help ..
Welcome to WebmasterWorld [webmasterworld.com]!
To redirect all files, just omit the list and use ".*"
Having done that, you can simplify this by removing one RewriteCond as well, by including the REQUEST_FILENAME pattern in the RewriteRule itself.
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www\.MY-DOMAIN\.com [NC]
RewriteRule !^Start-UP\.htm$ http://www.MY-DOMAIN.com/Start-UP.htm [NC,R=301,L]
Ref: Introduction to mod_rewrite [webmasterworld.com]
Jim
let's say I want to restrict jpg,gif and no-ext files.
I used:
RewriteRule \.(jpg¦¦gif)$ [nolinking.com...] [R,L]
OR
RewriteRule \.(jpg¦gif¦)$ [nolinking.com...] [R,L]
All I got is 500 server error.
Any Ideas?
If all these files are in one separate directory and nothing else is in this directory, you can just match the directory name. If they are spread all over the place it is more difficult.
Another way to do it would be to rename these files so that all included some special set of charactes, say "xz~zx" or something, then you could include this pattern in the rewrite rules. If the files have all kinds of funny names it is more difficult.
So the question is, what do these files have in common apart from no extension?
/claus