mod_rewrite - Module, File and Parameters

This is a discussion on mod_rewrite - Module, File and Parameters within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi there, I wrote an RewriteRule to rewrite URLs like http://example.org/<Module>/<Submodule>/<...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2007
Thomas Schager
 
Posts: n/a
Default mod_rewrite - Module, File and Parameters

Hi there,


I wrote an RewriteRule to rewrite URLs like
http://example.org/<Module>/<Submodule>/<File>.ext

to
http://example.org/index.ext?Module=<Module>&SubModule=<SubModule>Inc ludeFile=<File>

with
RewriteRule ^/(.*)/(.*)/(.*)\.ext$
/index.ext?Module=$1&SubModule=$2&IncludeFile=$3



What I was not able to do is:

(1) How can I parse any following parameters
(.../File.ext?do=var&do1=var1) to index.ext? Of course, these additional
parameters should be optional.

(2) How can I exclude directories like /images or /style from this
rewrite rule?



Many thanks in advance,
Thomas
  #2 (permalink)  
Old 02-23-2007
HansH
 
Posts: n/a
Default Re: mod_rewrite - Module, File and Parameters

"Thomas Schager" <thomas.schager@gmx.net> schreef in bericht
news:241f4$45df04cd$557c66d7$20424@news.inode.at.. .
> I wrote an RewriteRule to rewrite URLs like
> http://example.org/<Module>/<Submodule>/<File>.ext
> to
> http://example.org/index.ext?Module=<Module>&SubModule=<SubModule>Inc ludeFile=<File>
> with
> RewriteRule ^/(.*)/(.*)/(.*)\.ext$
> /index.ext?Module=$1&SubModule=$2&IncludeFile=$3
>
> What I was not able to do is:
> (1) How can I parse any following parameters
> (.../File.ext?do=var&do1=var1) to index.ext? Of course, these additional
> parameters should be optional.

Add a flag at the end of the rule [QSA]
>
> (2) How can I exclude directories like /images or /style from this rewrite
> rule?

Rather add a base folder to your concept to
http://example.org/base/<Module>/<Submodule>/<File>.ext

If you do not want to shift base, add before the rule
RewriteCond %{REQUEST_URL} !^/(images|scripts)/

HansH


  #3 (permalink)  
Old 02-23-2007
Thomas Schager
 
Posts: n/a
Default Re: mod_rewrite - Module, File and Parameters

> Add a flag at the end of the rule [QSA]
> If you do not want to shift base, add before the rule
> RewriteCond %{REQUEST_URL} !^/(images|scripts)/


Works perfect - big thanks!


Thomas
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:10 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0