Results 1 to 10 of 10
  1. #1

    .htaccess Redirect

    I would like to have visitors from a specific hostname redirected to a certain .php page. I would prefer to do this from the .htaccess file as I don't want to muck about to much with the code of my joomla installation (beside the plugin, module and theme ui's).

    Thank you for your help,

  2. #2
    Join Date
    May 2009

    Just remember, REMOTE_HOST AND REMOTE_ADDR are easily spoofed.

  3. #3
    Thank you very much for the help!

  4. #4
    I'm afraid it dosnt quite do what I want, I'm trying to setup a page which will come up if they are on the list. Basicly this will just say that they have been blocked. I would prefer to use hostnames at the moment (as I already have a list of hostnames to use). Thank you for your help!

  5. #5
    Join Date
    Mar 2005
    Are you speaking of blocking them via a 403 access denied. And send all 403/access denied to a custom page?

    Are these to be blocked via HTTP_REFERER, REMOTE_HOST, HTTP_USER_AGENT, or IP address?

  6. #6
    Join Date
    Mar 2005
    I posted the following below that would go in your .htaccess with a few examples.

    RewriteEngine On

    RewriteCond %{REMOTE_ADDR} ^38\.118\.42\.* [OR]
    RewriteCond %{HTTP_REFERER} example\.com [OR]
    RewriteCond %{HTTP_REFERER} spyfu\.com [OR]
    RewriteCond %{HTTP_USER_AGENT} "dejan" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "discobot" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "zermelo" [NC]
    RewriteRule ^.*$ [L,R]

  7. #7
    Thank you, but could you please explain it so I know how to mod it later, I'm a bit new to using the .htaccess.

  8. #8
    Join Date
    Jun 2007
    GA, USA
    Quote Originally Posted by neojames View Post
    Thank you, but could you please explain it so I know how to mod it later, I'm a bit new to using the .htaccess.
    Well, just look for some keywords.

    RewriteEngine On #This line is required to tell apache to turn on mod_rewrite support
    # REMOTE_ADDR is the IP of the person. Hostnames should resolve to IPs,
    # but personally I'd probably block IPs.
    # All lines below specify who is blocked
    RewriteCond %{REMOTE_ADDR} ^38\.118\.42\.* [OR] # This will block the IP range through (as denoted by the *)
    RewriteCond %{HTTP_REFERER} example\.com [OR] # Blocking a referer; who sent the user to the page
    RewriteCond %{HTTP_REFERER} spyfu\.com [OR] # Another of the above
    RewriteCond %{HTTP_USER_AGENT} "dejan" [NC,OR] # the user agent is a string browsers send to identify who they are (Ex: Mozilla/IE/Chrome/Safari/Opera will have a longish string with version info inside too
    RewriteCond %{HTTP_USER_AGENT} "discobot" [NC,OR] #So this, the line above and below are blocking specific user agents, in this case they are bots (spiders) (as most bots identify themselves with a unique user agent)
    RewriteCond %{HTTP_USER_AGENT} "zermelo" [NC] # Again with all of the above..
    RewriteRule ^.*$ [L,R] # ALl right! So if any of the above "RewriteCond"itions are met, the rule is to redirect all traffic "^.*$" to by redirection "[L,R]"
    Not the best with htaccess either, but that should give you the gist.

    .. and before you ask I figure I should throw out there that "#" is the comment symbol used in htaccess. Anything after it will not be executed which is how you can place plain text in the file..

  9. #9
    Thank you, i've been meaning to to that for a while! Thank You!

  10. #10
    Join Date
    Oct 2008
    Just what i needed, thanks!

Similar Threads

  1. .htaccess redirect
    By neojames in forum Web Design and Content
    Replies: 4
    Last Post: 10-02-2009, 05:55 AM
  2. .htaccess Redirect
    By tomyknoker in forum Hosting Security and Technology
    Replies: 4
    Last Post: 04-28-2008, 09:25 AM
  3. hmm I can't get my htaccess to redirect
    By lexington in forum Programming Discussion
    Replies: 6
    Last Post: 10-05-2007, 11:14 PM
  4. htaccess redirect 301
    By WebPhaser in forum Web Design and Content
    Replies: 3
    Last Post: 12-30-2005, 02:37 PM
  5. .htaccess redirect?
    By ENSupport in forum Hosting Security and Technology
    Replies: 9
    Last Post: 05-17-2003, 08:42 AM

Tags for this Thread

Posting Permissions

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