Jump to content

why don't these work when together


Exoon

Recommended Posts

Hello, ive got these two rules and they work fine when there on their own but as soon as i put them together only the one at the top works. How can i have both these rules?

 

RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&id=$2& [L,NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&console=$2& [L,NC]

Link to comment
https://forums.phpfreaks.com/topic/147147-why-dont-these-work-when-together/
Share on other sites

the difference is one is using id and one is using console.

 

I want it so its like

 

index.php?page=reviews&id=7    goes to >>    /reviews/7/

index.php?page=games-list&console=ps3    goes to >>  /games-list/ps3/

 

but only one of them works. How can i get both working?

that isn't how it works though, it's the other way around:

 

/reviews/7/    goes to >>    index.php?page=reviews&id=7

/games-list/ps3/    goes to >>  index.php?page=games-list&console=ps3

 

that being said, both the first and second examples will match the first REGEX. i would switch it to something more generic, like this:

 

RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&topic=$2& [L,NC]

then adjust your reviews code to map $_GET['topic'] to the id and your games-list code to map $_GET['topic'] to the console

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.