This is a discussion on URLRewrite problem (seems it continues rewriting in spite of [L]) within the Apache Web Server forums, part of the Web Server and Related Forums category; It seems very simple, but I'm already about knocking my head against walls. I want urls like "http://...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
It seems very simple, but I'm already about knocking my head against
walls. I want urls like "http://host/dir/blabla" to be rewritten to "http://host/dir/script.php?param=blabla" The following .htaccess is put into /dir/ ---- .htaccess --- RewriteEngine On RewriteRule ^(.*)$ script.php?param=$1 [L] ----------------------- The script.php ( in /dir/) gets "param" as "script.php". If I use something like RewriteRule ^([^s].*)$ script.php?param=$1 [L] the engine works as I want. So, what's up? Thank you! |
|
|||
|
"rr" <anatoly.rr@gmail.com> schreef in bericht
news:1165424677.534833.121310@80g2000cwy.googlegro ups.com... > I want urls like "http://host/dir/blabla" to be rewritten to > "http://host/dir/script.php?param=blabla" > > The following .htaccess is put into /dir/ > RewriteEngine On > RewriteRule ^(.*)$ script.php?param=$1 [L] > > The script.php ( in /dir/) gets "param" as "script.php". > > If I use something like > RewriteRule ^([^s].*)$ script.php?param=$1 [L] > the engine works as I want. > > So, what's up? Your destination after rewrite is in the same folder, either put it elsewhere or exclude it from the rewrite: RewriteCond %{SCRIPT_URL} !/script\.php$ RewriteRule (.*) script.php?param=$1 [L] HansH |
|
|||
|
rr wrote:
> It seems very simple, but I'm already about knocking my head against > walls. > > I want urls like "http://host/dir/blabla" to be rewritten to > "http://host/dir/script.php?param=blabla" An internal redirect is performed after a URL rewrite, which will re-execute all of the rules in .htaccess causing infinite recursion. I like to check if a status variable is set and be done. Also you don't need the end-of-line anchor since regexps are greedy by default. RewriteCond %{ENV:REDIRECT_ISDONE} ="" RewriteRule ^(.*) script.php?param=$1 [E=ISDONE:1,L] --Randall |