LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-03-2012, 04:30 AM   #1
vishalsamyal
LQ Newbie
 
Registered: Oct 2012
Location: India
Posts: 25
Blog Entries: 3

Rep: Reputation: Disabled
Ref-feral check in apache


Hello,

I am facing problem while adding ref-reral check in apache. Like

Whenever any one hit "http://abc.com/def/now.do", "now.do" file is opening.I want when ever anyone hit "http://abc.ocm/def/now.do". It should not be open, but when ever hit comes from internal java application It should responce to java application.

I am applying following rule, But it's not working,

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} ^http://abc.com/ [NC]
RewriteRule ^/def\.(do)$ - F

Any help will be appreciable.
 
Old 11-03-2012, 09:07 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

First of all you have an error in the RewriteRule. You have to enclose F with square brackets (like [F])
Also your problem description is not very clear. I guess you don't want anyone to access /def/now.do (or is it for any .do file?), if it's not coming from your server.
In this case you can put in apache .conf file the following:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://abc.com/ [NC]
RewriteRule ^/def/(.do)$ - [F]
Regards
 
Old 11-03-2012, 09:57 AM   #3
vishalsamyal
LQ Newbie
 
Registered: Oct 2012
Location: India
Posts: 25

Original Poster
Blog Entries: 3

Rep: Reputation: Disabled
Thanks for your reply, But apache is still serving this url:

I do not want that apache serve for any request that comes to directly "http://abc.com/def/*.do".
Example:
http://abc.com/def/abc.do ----- should not serve.
http://abc.com/def/xyz.do ----- should not serve.

I want only one thing that is "http://abc.com/def/*.do" should not open directly in any internet explorer like(firefox, google chrome, IE.

Any help will be appreciable.
 
Old 11-03-2012, 03:48 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
If you want to allow access to *.do only from a specific page, through a link or something, then use:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://abc.com/specific.html$ [NC]
RewriteRule ^/def/(.do)$ - [F]
Cheers
 
Old 11-05-2012, 03:12 AM   #5
vishalsamyal
LQ Newbie
 
Registered: Oct 2012
Location: India
Posts: 25

Original Poster
Blog Entries: 3

Rep: Reputation: Disabled
If I want to allow *.do to multiple html pages, Then?
Actually I have to allow it for multiple pages in the website.
 
Old 11-05-2012, 06:16 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by vishalsamyal View Post
If I want to allow *.do to multiple html pages, Then?
Actually I have to allow it for multiple pages in the website.
You must see if there is a common pattern for those pages and use that in the RewriteCond line. Or use an [OR] flag like:
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://abc.com/one.html$ [NC,OR]
RewriteCond %{HTTP_REFERER} !^http://abc.com/two.html$ [NC,OR]
...
RewriteCond %{HTTP_REFERER} !^http://abc.com/last.html$ [NC,OR]
RewriteRule ^/def/(.do)$ - [F]
 
Old 11-05-2012, 06:24 AM   #7
vishalsamyal
LQ Newbie
 
Registered: Oct 2012
Location: India
Posts: 25

Original Poster
Blog Entries: 3

Rep: Reputation: Disabled
Thx for your reply..

But with this rule I am getting the same error on even on "http://abc.com/one.html".
This url is also not opening and still getting "*.do" file in browser.

Last edited by vishalsamyal; 11-05-2012 at 11:24 AM.
 
Old 11-05-2012, 11:30 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by vishalsamyal View Post
Thx for your reply..

But with with rule am getting the same error on even on "http://abc.com/one.html".
This url is also not opening and still getting "*.do" file in browser.
What error you get?
I had a typo in the rewrite rule, so you may try the following:
Code:
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://abc.com/(one|two|last).html$
RewriteRule ^/def/(.*).do$ - [F]
 
Old 11-06-2012, 02:33 AM   #9
vishalsamyal
LQ Newbie
 
Registered: Oct 2012
Location: India
Posts: 25

Original Poster
Blog Entries: 3

Rep: Reputation: Disabled
I applied the that url like :

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://abc.com/(one|two|last).html$
RewriteRule ^/def/(.*).do$ - [F]

But with this rule "http://abc.com/def/lsthw.do" is still opening in browser. And I do not want that browser opened this url anymore.
 
Old 11-06-2012, 03:24 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
But with this rule "http://abc.com/def/lsthw.do" is still opening in browser. And I do not want that browser opened this url anymore.
Then delete the line
Quote:
RewriteCond %{HTTP_REFERER} !^$
Cheers
 
Old 11-06-2012, 04:53 AM   #11
vishalsamyal
LQ Newbie
 
Registered: Oct 2012
Location: India
Posts: 25

Original Poster
Blog Entries: 3

Rep: Reputation: Disabled
No!! it's not working.

Anyway thx for your reply!!!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Install Mimms in my Feral Slice Dinamiz72 Linux - Software 4 08-24-2012 12:37 PM
gfortran 4.1 equivalent with %val %ref Rexy Programming 0 06-24-2009 06:17 PM
LXer: Are Linux users really a feral bunch? LXer Syndicated Linux News 0 11-05-2007 08:00 PM
Ref. ImageMagick, saving stabu Slackware 1 01-08-2006 11:39 AM
Ref Email File rigel_kent Programming 0 09-13-2005 12:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration