mod_rewrite help

mod_rewrite help

am 07.09.2009 14:08:03 von Lars Solberg

Hello list!

I know basic mod_rewrite, not much, but enough to create basic rules.

Now I need to create a rule that can handle this situation:
* Work under the root (/) folder
* Don't do anything under the /secure/ folder
* Don't do anything with *.js, *.jpg
* Rewrite everything else to index.php?bad_request=%URL%

Any tips, hint, solutions? :-)

Thanks!

Regards
Lars

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: mod_rewrite help

am 07.09.2009 14:20:50 von Eric Covener

On Mon, Sep 7, 2009 at 8:08 AM, Lars wrote:
> Hello list!
>
> I know basic mod_rewrite, not much, but enough to create basic rules.
>
> Now I need to create a rule that can handle this situation:
> =A0* Work under the root (/) folder
> =A0* Don't do anything under the /secure/ folder
> =A0* Don't do anything with *.js, *.jpg
> =A0* Rewrite everything else to index.php?bad_request=3D%URL%

this is probably close:

RewriteCond %{REQUEST_URI} !^/secure/
RewriteCond %{REQUEST_URI} ! \.(js|jpg)$
RewriteCond %{QUERY_STRING} !bad_request
RewriteRule (.*) /index.php?bad_request=3D$1

"If it doesn't begin with /secure, end in js/jpg, or is already
rewritten as a bad request, rewrite it."

--=20
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: mod_rewrite help

am 07.09.2009 14:36:08 von Lars Solberg

Wow, that was a fast answer :)

I tried it, and got "RewriteCond: bad flag delimiters" and 500 error.
Saw that there was an extra space in the "RewriteCond %{REQUEST_URI} !
\.(js|jpg)$" rule, so changed it to "RewriteCond %{REQUEST_URI}
!\.(js|jpg)$".
Got rid of the 500 error, but now the rule didnt do anything at all..

Is there anything obvious i'm missing here?

Thanks

Lars

On Mon, Sep 7, 2009 at 2:20 PM, Eric Covener wrote:
> On Mon, Sep 7, 2009 at 8:08 AM, Lars wrote:
>> Hello list!
>>
>> I know basic mod_rewrite, not much, but enough to create basic rules.
>>
>> Now I need to create a rule that can handle this situation:
>> * Work under the root (/) folder
>> * Don't do anything under the /secure/ folder
>> * Don't do anything with *.js, *.jpg
>> * Rewrite everything else to index.php?bad_request=%URL%
>
> this is probably close:
>
> RewriteCond %{REQUEST_URI} !^/secure/
> RewriteCond %{REQUEST_URI} ! \.(js|jpg)$
> RewriteCond %{QUERY_STRING} !bad_request
> RewriteRule (.*) /index.php?bad_request=$1
>
> "If it doesn't begin with /secure, end in js/jpg, or is already
> rewritten as a bad request, rewrite it."
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org