theCrandallSter

November 18, 2009

Using .htaccess for Form Processing and URL Redirects

Filed under: Uncategorized —theCrandallSter @ 4:57 pm

The Quick and Dirty

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^goto/([a-z]+)/?$ /$1/ [R]
</IfModule>

What it does

This allows us to request URLs like:

http://blog.blah.beep/login/goto/home
http://blog.blah.beep/login/goto/home/
and it would redirect us to
http://blog.blah.beep/home/

Why I believe this is useful

It could be used for passing values between form submissions and destination pages gracefully, without having to use header(“location: http://blah.beep“) inside page’s code.

By checking the referrer address, you could use it like an array key to load a file located in the destination directory to handle the parameters for that specific referrer. By doing this, pages that receive form data from many different locations will be easier to troubleshoot and manage, because there would not be gigantic files to go through; everything would be organized and separate from each other.

Why it probably is secure…

“I think as long as the server is configured correctly and the files handle authentication autonomously, then it shouldn’t be a security issue. Also, being that the rewrite rule only works with characters a-z and one slash I doubt they could jump around directories by injecting stuff into the URL, I think…”

Probably is not enough: Determining if it is Secure

http://serverfault.com/questions/86043/htaccess-redirect-is-it-secure

I posted this earlier today, and I haven’t heard back yet. When I do I will post how the community feels about the idea. I am not concerned if I may be wrong; knowledge gained from this attempt would be enough for me.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress