Trying to redirect using mod_rewrite

Posted on 2005-04-25
Last Modified: 2010-03-04
okay, we are trying to use mod_rewrite to send all our files over to coldfusion file of ours.

What we would like to run is this...

RewriteEngine On
RewriteRule ^(.*)$ /error_docs/not_found.cfm?id=%{REQUEST_URI} [L]

now, with this, i presume the following urls will go to this..... => => =>


this is what we would like to get working....

however, when the previous code is placed in the .htaccess file, we get a "Internal Server Error".

What are we doing wrong?

When i run the code below, it runs fine:

RewriteEngine On
RewriteRule ^.$ /error_docs/not_found.cfm?id=%{REQUEST_URI} [L]

but of course, this only redirects for a single character entered...of course. But, at least we know that some for of mod_rewrite runs on our server.

Is there anything special that we need to do w/ httpd.conf?

Any help would be gratefully appreciated.

Question by:iqDevs
    LVL 14

    Assisted Solution

    Have you tried using the backreference as a variable?

    RewriteEngine On
    RewriteRule ^(.*)$ /error_docs/not_found.cfm?id=$1
    LVL 51

    Accepted Solution

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/error_docs/
    RewriteRule ^(.*)$ /error_docs/not_found.cfm?id=$1 [L]

    Author Comment

    bah, figured it out

    apparently my file path was messed up

    RewriteEngine On
    RewriteRule ^.$ error_docs/not_found.cfm?id=%{REQUEST_URI} [L]

    this seems to work great now.
    LVL 51

    Expert Comment

    this works? fascinating, unbelievable, ..

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now