Mark
Mark

Reputation: 113

Simple mod rewrite with PHP Get values

can someone tell me what in the world I'm doing wrong?

trying to take:

search.php?key=23&category=testing

and make:

/23/testing.html

with this:

RewriteRule ^([^/]*)/([^/]*)\.html$ /?key=$1&category=$2 [L]

For the life of me I can't figure this out...or if there is a better way, please point me in the right direction.

** UPDATE

Ok, after giving up on this I finally contacted the hosting company to see if there was a problem with my domain that was keeping this from working. Here is what they told me:

  1. You do not have a rewrite condition and you only have a simple rewrite. For the code to >always work properly you should normally set a "RewriteCond" with a valid pattern.

  2. You have used the "?" question mark character in your code although this is an escape >character and doing so would only cause a rewrite to index.php based upon your code as >everything after the question mark gets escaped.

Please consider using a "RewriteCond" in your code and also use regexes to properly escape >the "?" character and avoid unexpected behavior.

Can anyone give me some help? Thanks!

Upvotes: 0

Views: 65

Answers (1)

Emery King
Emery King

Reputation: 3534

RewriteRule ^/([^/]*)/([^/]*)\.html$ /?key=$1&category=$2 [L,R]

Upvotes: 1

Related Questions