Welcome to WebmasterWorld Guest from 54.144.48.252

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite: problem with a dot

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

10+ Year Member



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!

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

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



Yes, i am using just a Notepad for the editing
9:02 pm on Feb 5, 2005 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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

The period is: .

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

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month