Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts

    htaccess - redirect to a file without using full adress

    Hi!
    is that possible do redirect to a file/page/dir that located on same server, but dont use full path to it?
    for example, this antileach code:
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/nasty.gif [R,L]
    as u see it will redirect to http://www.yourdomain.com/nasty.gif but, I have different domains that point to same site, so, whenever some trying to leach it will show picture from one of domains.
    so, is there a way use somesort of {HTTP_SELF}/nasty.gif or whatever that will use currently opened domain name?

    also, where can I find more info about such a things, not just general info about .htaccess files, the more advanced info?

    thanks

  • #2
    New Coder dragon's Avatar
    Join Date
    May 2003
    Location
    Florida
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Couldn't you just put additional lines like:
    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?your2nddomain.com/.*$ [NC]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?your3rddomain.com/.*$ [NC]
    RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/nasty.gif [R,L]

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yep, that's the only way I know...
    thought maybe there is different way to do same thing, with just one tag....ouh well.
    thx fro the reply

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rewrite conditions and rules are regular expression patterns, so you should be able to do that.

    Instead of the 3 conditions dragon wrote

    RewriteCond %{HTTP_REFERER} !^http://(www\.)?(domain1|domain2|domain3).com/.*$ [NC]
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #5
    Regular Coder
    Join Date
    Feb 2003
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no, I dont have a problem to find out whitch domain in use, but the problem is to redirect to the same domain on the error page.
    also, I have custom 404, 403 and 500 error pages but whatever domain in use it will redirect to whatever I specify, not to the same one...hope this is more clear now.

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No - less clear actually.

    paint me a picture
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #7
    Regular Coder
    Join Date
    Feb 2003
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it's not about a picture, its not about the antileach (it was just an example )
    ok, one more time:
    1. I have several domains that point at the same IP, same site.
    2. the site has custom error messages.
    3. in .thaccess I have to specify the full address for the error document, right?
    4. because of that I only can specify one address where the error document is, that cause that when error accur at another domain name (remmber it's same site, same document_root, same .htaccess, just different domain names) it will use document that points to the specific from the .htaccess error document. After that, the visitor has to either hit back button or continue surf at "new" domain name...

    just to make it more clear the real example:
    http://come.no-ip.com
    and
    http://gallery.vanowm.com
    two different domains but same site.
    now, lets try this, not existing document:
    http://come.no-ip.com/nothinghere.html
    and
    http://gallery.vanowm.com/nothinghere.html
    as u can see it opens error page but with the same domain name...
    is there a way around it?
    (I think it can be done in the apache http.conf file, but its not the case...)
    btw, almost forgot to thank you for the replys

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh - no, it's much simpler than that. This doesn't require url rewriting at all

    ErrorDocument 404 /index.php?error=404
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #9
    Regular Coder
    Join Date
    Feb 2003
    Posts
    101
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well...I have tryed that before, it works only if the error acure in the root dir.
    for exmaple, if the root is / and error acure in /something/here/ then it will try open error page not at root ( /index.php?error=404 ) but at current location ( /something/here/index.php?error=404 ) that become no ending cicle...

    so, so far the only way I can think of is add for each virtualhost personal errordocument path...
    Last edited by V@no.; 05-16-2003 at 03:17 AM.

  • #10
    New to the CF scene
    Join Date
    May 2003
    Location
    Mexico
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I seem to remember that you can give directories an alias, well think about it.
    alias a folder for errors as in /error/
    then when you reference it from whatever other folder it refers to the inline tree of folders it knows, since that is aliased it would know it as well.

    Now I was also referencing this as basically in Apache. I have seen many references to doing this, but have not yet had a need for exactly this, so do not know how it is done.. but gives you something to look up...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •