Results 1 to 4 of 4
  1. #1

    mod rewrite redirect - semi complicated

    Hi All,

    I've been trying to figure out how to accomplish a specific type of redirect using htaccess, modrewrite, etc.

    Here's the story in a nutshell:

    I run a forum. In the forum I post threads which, when clicked, automatically redirect to static html pages located elsewhere on my site.

    What I'm trying to set up is a system that checks to make sure that a viewer is coming from the forum thread, and not linking to the page directly, or basically not coming from anywhere else. I only want people following the thread links to be able to access the end pages, and I want to redirect everyone else to a different page (like a "Hey, stop trying to bypass the system" kind of page)

    Where it gets a little complicated is that my forum software sometimes sticks on session tags to URLs, so that when you browse around the forum, the URL in the browswer has all the session info in it. I don't know how to deal with this.

    Can anyone help?

    Thanks in advance.

  2. #2
    Join Date
    Apr 2003
    San Jose, CA.
    RewriteEngine On

    RewriteCond %{HTTP_REFERER} !^ [NC]
    RewriteRule ^(.*) [L]


    put that in a .htaccess file in a directory where your static content is.
    That would make it so that if someone went directly to the static content (ie not linked from the forum) they would get redirected back to the main page.

  3. #3
    What are the "[NC]" and "[L]"?

    Thanks for the reply

  4. #4
    Join Date
    Mar 2003
    Sacramento, CA
    'nocase|NC' (no case)
    This makes the test case-insensitive, i.e., there is no difference between 'A-Z' and 'a-z' both in the expanded TestString and the CondPattern. This flag is effective only for comparisons between TestString and CondPattern. It has no effect on filesystem and subrequest checks.

    'last|L' (last rule)
    Stop the rewriting process here and don't apply any more rewriting rules. This corresponds to the Perl last command or the break command from the C language. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('/') to a real one, e.g., '/e/www/'.

    As listed at:
    Jacob Squires , CISSP

    security assesment, network analysis

Posting Permissions

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