httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Georg Markus Dittrich <gor...@yahoo.de>
Subject [users@httpd] mod_rewrite & query strings -> php variables, sessions
Date Tue, 19 Nov 2002 18:32:21 GMT

hello,

following problem - every help appreciated (Apache 1.3 newest version on redhat linux, rewriting
urls on htaccess level):

to put it in a nutshell i would like to know, how i can include the query_string in rewrite
rules not only on the output side, but on the incoming one (the URL, which has to be rewritten);

I use the following rule:

^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)\.html $1\.php?category=$2\&item=$3\&shop_lang=$4\&type=$5

to rewrite URL´s like http://www.maskworld.com.exxs.net/display-department_152_0_german_beard.html


to an URL like http://www.maskworld.com.exxs.net/display-department.php?category=152&item=0&shop_lang=german&type=beard


This way it appears that the page is made of static pages and search engines can spider them.

But still I want to use sessions without cookies in PHP and transfer variables with url-encode.
That is why I would like to use the following rule, as PHP attaches it´s session variable
and other data automatically after the xxx.html):

RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)\.html\??(.*) $1\.php?category=$2\&item=$3\&shop_lang=$4\&type=$5\&$6

but this does not work. I have found out that it has something to do with the ´?´ at the
beginning that starts the query_string. As I am rewriting the URL myself I already have the
? in my new URL and therefore would like to paste all the stuff that comes in the original
URL behind the last variable ($6).

But apparently mod_rewrite has a general problem with ? marks. I tried to escape it and use
the second one as a {1,0} indicator as there might be a session_id or not. But it does not
work either way.

By reviewing the logs I have found out, that no matter how I define the rule, when I call
an URL like http://www.maskworld.com.exxs.net/display-department_152_0_german_beard.html?shit=5
the server initialises the rewrite process with the URL http://www.maskworld.com.exxs.net/display-department_152_0_german_beard.html,
but without the remaining characters after the .html. So everything after the question mark
is ignored? Why? Why is there nowhere documentation on this topic, or is there? How can I
fix this? there has to be a way to work with the session variables; OT: could I get php to
work with a different variable introductor? /OT Would this work with the rewrite then?

I have worked for a while now, but I am stuck - any help is greatly appreciated. 

thanx a lot in advance - gorg.



---------------------------------
Gesendet von http://mail.yahoo.de.
3,5% Zinsen ab dem 1. EUR. Das Tagesgeldkonto mit den besten ZinsenTäglich verfügbar.
 Kostenlose Kontoführung. Jetzt eröffnen! Extrakonto bei der DiBa.
Mime
View raw message