You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Emil Edeholt <em...@knmedical.se> on 2008/06/09 12:38:23 UTC

[users@httpd] Rewrite ?

Hi!

I want url:s like site.com/page/subpage/some=data and I also need urls 
like site.com/foo/bar/?some=data to function on my site. The first kind 
works fine. But I can't get the question mark-kind to work.

This works fine for case 1:
RewriteRule ^([a-z]*[/][a-z]*)[/]?([a-z0-9=&])$ 
/main_script.php?=the_page=$1&$2

I added a [\?]?, case 1 still works but case 2 does not (the page $1 is 
passed fine, but the rest of the data $2 is not passed at all):
RewriteRule ^([a-z]*[/][a-z]*)[/]?[\?]?([a-z0-9=&])$ 
/main_script.php?=the_page=$1&$2

Any ideas?

Best Regards Emil

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> 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: [users@httpd] Rewrite ?

Posted by Martin Barry <ma...@supine.com>.
$quoted_author = "Emil Edeholt" ;
>
> I want url:s like site.com/page/subpage/some=data and I also need urls  
> like site.com/foo/bar/?some=data to function on my site. The first kind  
> works fine. But I can't get the question mark-kind to work.

The second type is handled by Apache as HOST/PATH?QUERY_STRING and hence you
need to specifically match on QUERY_STRING.

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

...and read the bits "What is matched?" and "Modifying the Query String"

cheers
marty

-- 
"It might have been the time we went for a pub lunch. He ordered food, and I
ordered a beer. After sitting down, He asked me what I was having for lunch
and I raised my glass. He protested I couldn't just have a beer for lunch,
so I went back to the bar and got a second beer." --Peter Corlett

alt.sysadmin.recovery - <eg...@mooli.org.uk> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> 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