mod_rewrite bug(

Discuss practical ways rearrange URLs using mod_rewrite.

mod_rewrite bug(

Postby Dimka » Thu Dec 16, 2004 6:33 pm

Hello
I am new on this forum, donno how it goes here, hope made this thread in the right place in no plz don’t punish me).
I have a bug in my code, spent a few hours on that and can't find any solution hope somebody could give me a hand, I would really appreciate that.

Here is the deal


Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# Rule One main.php?act=data&pic=pix1&set_lang=en -> data-pix1-en.htm
RewriteRule (.*)-(.*)-(.*)\.htm$ /main.php?act=$1&pic=$2&set_lang=$3
# Rule Two main.php?act=data&pic=pix1 -> data-pix1.htm
RewriteRule (.*)-(.*)\.htm$ /main.php?act=$1&pic=$2
# Rule Three main.php?act=data&set_lang=en -> data-en.htm
RewriteRule (.*)-(.*)\.htm$ /main.php?act=$1&set_lang=$2
# Rule Four main.php?act=data -> data.htm
RewriteRule (.*)\.htm$ /main.php?act=$1



With this code everything works Except for Rule number Three but if I will replace it with Rule number one it will work but Rule number one won't. I am confused and don't know where is the bug

Any advices are welcome
Thanks in advance
Dimka
 
Posts: 1
Joined: Thu Dec 16, 2004 6:08 pm

Postby Caterham » Fri Dec 17, 2004 8:08 am

try to modify the regular expression to

Code: Select all
(.*)-pix(.*)\.htm$


Code: Select all
Options +FollowSymLinks
RewriteEngine on
# Rule One main.php?act=data&pic=pix1&set_lang=en -> data-pix1-en.htm
RewriteRule (.*)-(.*)-(.*)\.htm$ /main.php?act=$1&pic=$2&set_lang=$3
# Rule Two main.php?act=data&pic=pix1 -> data-pix1.htm
RewriteRule (.*)-pix(.*)\.htm$ /main.php?act=$1&pic=pix$2
# Rule Three main.php?act=data&set_lang=en -> data-en.htm
RewriteRule (.*)-(.*)\.htm$ /main.php?act=$1&set_lang=$2
# Rule Four main.php?act=data -> data.htm
RewriteRule (.*)\.htm$ /main.php?act=$1


bob
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Guest » Sat Dec 18, 2004 4:37 pm

Thank you very much it solved the problem :D
Guest
 


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 29 guests

cron