|
|
| Author |
Message |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Sat Mar 06, 2004 11:24 pm Post subject: |
|
|
|
I've already read the section on google tap, and many other resources, but cannot find a mention of spaces anywhere.
I did try and put a space in, although I escaped it as I thought it might have caused probs as the space is also used to seperate the 2 URLs.
I will try just putting a space in and also try with a % and see what happens.
Steve
[EDIT] Just tried it with the space and remembered I have tried it. Putting a space into the .htaccess file where stated causes an Internal Server Error and the site goes down. Putting a space in the stated place in header.php causes errors on those lines.
[EDIT2] The same happens with the % sign.
I think the only option is to replace the space with an underscore before it's converted to a friendly URL by header.php. Possibly have it replaced and output it to another variable ($query2) and then use this in the URL linking to the protections database mod. Then put some code in the search function i put into the protections db mod to take out the space (or spaces).
I have the ideas, but I dunno how to implement them  |
|
| Back to top |
|
 |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Sun Mar 07, 2004 1:03 am Post subject: |
|
|
|
Well, i've decided not to bother with anything hard. We don't need to have the rewriting in effect in the search module. So I found a way to stop it from happening on the search module for the link to the protections db.
Instead of having: | Code: | $mod4 = "<li> <a href=\"modules.php?name=Protections_Database&
op=search&query=$query\">Protections Database</a> ($pcnt "._SEARCHRESULTS.")"; |
I now have | Code: | $mod4 = "<li> <a href=\"http://www.makeabackup.com/modules.php?
name=Protections_Database&op=search&query=$query\">
Protections Database</a> ($pcnt "._SEARCHRESULTS.")"; |
I figured putting the full URL into the link would stop it from being picked up by the rewrite code in header.php and I figured right.
The link works fine too. So no probs now.
Thanks for your help.
Steve |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Sun Mar 07, 2004 7:58 am Post subject: |
|
|
|
Finally, someone who really follows the KISS principle!
PS. In case someone wants to use mod_rewrite with IIS, here is the solution: mod_rewrite with IIS. _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Sun Mar 07, 2004 12:14 pm Post subject: |
|
|
|
The KISS principal?  |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Sun Mar 07, 2004 2:43 pm Post subject: |
|
|
|
Keep It Simple and Stupid!  _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Sun Mar 07, 2004 4:24 pm Post subject: |
|
|
|
| Ahh |
|
| Back to top |
|
 |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Wed Mar 10, 2004 7:51 pm Post subject: |
|
|
|
Am having another problem with another rewrite.
I am trying to get the RE | Code: | | "'(?<!/)modules.php\?name=Downloads&d_op=viewdownloaddetails&lid=([0-9]*)&ttitle=([a-zA-Z0-9_-]*)'", |
to also take the % sign but I am stuck. i know the SMGL and Unicode for it | Code: | | & percnt ; and & # x0025 ; |
but am having trouble putting it in. i have already tried | Code: | | "'(?<!/)modules.php\?name=Downloads&d_op=viewdownloaddetails&lid=([0-9]*)&ttitle=([a-zA-Z0-9_-& # x0025 ;]*)'", |
but with no luck.
Had to put spaces into the SMGL and unicode as it didn't want to display it here.
Any ideas on this one? The reason I need it is because 2 of the downloads have % in the name.
Steve |
|
| Back to top |
|
 |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Thu Mar 11, 2004 2:38 am Post subject: |
|
|
|
Well, I've been working on this for several hours now. I figured out that I could take a KISS approach and do a seperate rewrite for every download that had a %. Then I found out that there's an entire section that has backslashes and brackets in the URLs.
I have managed now to get the header.php file to rewrite the these URLs into friendly ones.
Wana know how?
Well, you're gona find out anyway - I've just done it for one link (the details on each file). I edited index.php in the downloads module so that all links like the first one were changed to the second one: | Code: | <a href=\"modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle\">
<a href=modules.php?name=$module_name&d_op=viewdownloaddetails&lid=$lid&ttitle=$transfertitle&1> |
I then used this line to catch the URL | Code: | | "'(?<!/)modules.php\?name=Downloads&d_op=viewdownloaddetails&lid=([0-9]*)&ttitle=(.*)&1'", |
N.B. I found just puting in (.*) knocked the .html part of the rewrite off and it was echoed at the bottom of the table. I figured the RE was reading more than I wanted it to. Puting in something which is static at the end gives it an ending (as such).
This is then rewriten to | Code: | | "downdetails\\1-\\2-1.html", |
It wont work without the -1 (or something else) on the end.
My problem now is that i have updated the .htaccess file to read | Code: | | RewriteRule ^downdetails([0-9]*)-(.*)-1.html modules.php?name=Downloads&d_op=viewdownloaddetails&lid=$1&ttitle=$2&1 |
but this throws up an error | Code: | | Client sent malformed Host header |
This happens on any URL with % in it, I guess it happens with brackets and backslashes too.
Does anyone know how to write the code in .htaccess to get around this problem?
I have checked the google tap files and they would get stuck where I was stuck before.
Thanks In Advance
Steve |
|
| Back to top |
|
 |
chris Dark Lord of the Sith

Joined: 10 May 2003 Posts: 6262 Location: Outer Space
|
Posted: Mon Mar 15, 2004 11:10 am Post subject: |
|
|
|
| Steve wrote: | Am having another problem with another rewrite.
I am trying to get the RE | Code: | | "'(?<!/)modules.php\?name=Downloads&d_op=viewdownloaddetails&lid=([0-9]*)&ttitle=([a-zA-Z0-9_-]*)'", |
to also take the % sign but I am stuck. i know the SMGL and Unicode for it | Code: | | & percnt ; and & # x0025 ; |
but am having trouble putting it in. i have already tried | Code: | | "'(?<!/)modules.php\?name=Downloads&d_op=viewdownloaddetails&lid=([0-9]*)&ttitle=([a-zA-Z0-9_-& # x0025 ;]*)'", |
but with no luck.
 |
Did you try
| Code: |
"'(?<!/)modules.php\?name=Downloads&d_op=viewdownloaddetails&lid=([0-9]*)&ttitle=([a-zA-Z0-9_-%]*)'"
|
Note that [a-zA-Z0-9_-%] is a so-called "character class". It means a small letter (a-z), a big letter (A-Z), a number (0-9), an underscore, a dash or a percent sign. The star after it means "zero or more occurences of the previous character". Since the "previous character" is one of the above, the whole thing means "zero or more occurences of alphanumeric characters, underscores, dashes, or percent signs" - and should work.
Your URLs have percent signs probably because they contain blanks (which, correctly written, are transformed to "%20" before the URL is sent by your browser to the server). You might avoid the whole problem if you transformed blanks to underscores in your URLs.
Also, take a look at the mod_rewrite RewriteRule generator, play a little around with it and tell me if it helps (I'm not sure about this). _________________ Regards
Chris Karakas
www.karakas-online.de |
|
| Back to top |
|
 |
Steve Warrant Officer

Joined: 01 Oct 2003 Posts: 73
|
Posted: Mon Mar 15, 2004 7:12 pm Post subject: |
|
|
|
I tried it with the % signs and got an error, see earlier post. I'll give the generator a try.
I know quite a lot about mod_rewrite now, so i understand what most of it means.
I decided to take the KISS pproach again, and just left out those two URLs. The percent sign isn't because of any spaces, it's because the name of 2 of the files has the percent sign in it: Alcohol_120% and Alcohol_52%. I've already asked the guy in charge if he'll drop the percent sign but he's saying NO as it is part of the name.
His loss.
Thanks for helping again.
Steve |
|
| Back to top |
|
 |
|
|
 |
|
|