homepage Welcome to WebmasterWorld Guest from 54.204.141.129
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod_rewrite: problem with a dot
Philarmon




msg:1503946
 6:24 pm on Feb 5, 2005 (gmt 0)

Hi!

i am having troubles with the mod_rewrite and hope you gurus can help me :)

I am trying to rewrite an url so the output says "...&platform=Game.com" , but all i get is "Game com" - the dot seems to be lost. This is my current code:

RewriteRule ^games-Game_com.html$ /index.php?module=games&platform=Game\.com [L]

I have tried to escape the dot with a "\" and i've tried it without the backslash - with no luck.

Thank you for your time!

 

jdMorgan




msg:1503947
 7:58 pm on Feb 5, 2005 (gmt 0)

I haven't seen this problem before... Are you using a plain text editor like Notepad or vi to do the editing?

The other possibility is that "." is not allowed in query strings, but I don't see why that would be a necessary restriction in HTTP.

Jim

Philarmon




msg:1503948
 8:34 pm on Feb 5, 2005 (gmt 0)

Yes, i am using just a Notepad for the editing

jdMorgan




msg:1503949
 9:02 pm on Feb 5, 2005 (gmt 0)

I can't say why that doesn't work. It may just be a problem with "." being an invalid character in aquery string.

As a work-around, I'd suggest rewriting to ...&platform=Game_com, and then using preg_replace in your script to fix it.

Jim

zollerwagner




msg:1503950
 8:44 am on Feb 6, 2005 (gmt 0)

I wonder what would happen if you were to translate the period into hex code?

The period is: .

Marino




msg:1503951
 10:35 am on Feb 6, 2005 (gmt 0)

Hello,

Not a guru, but not escaping a dot in a regexp is wrong, even if in this case, it would not change the behaviour, a dot in a regexp meaning "whatever character", and thus, a dot ;-) On the contrary, you musn't escape the dot in the substitution string.

Then, there is concern about the paths. If you are using a RewriteBase directive before your rewrite rule, it should work better (I guess) :

RewriteBase /
RewriteRule ^(.*)games-Game_com\.html$ $1/index.php?module=games&platform=Game.com [R,L]

You may refine the RewriteBase directive to fit your needs. If the games-Game_com.html url and the index.php url are in the same directory, you can avoid the .* pattern (I learned here why to avoid it).

RewriteBase /mydirectory
RewriteRule ^games-Game_com\.html$ index.php?module=games&platform=Game.com [R,L]

You could also create a .htaccess file in the directory itself, and get rid of the RewriteBase directive.

Let us know if it worked.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved