Forum Moderators: phranque

Message Too Old, No Replies

.HTML to .PHP not quite working

         

Karma

2:47 pm on Aug 16, 2011 (gmt 0)

10+ Year Member



I am trying to mod_rewrite the following:

mydomain.tld/ --> mydomain.tld/index.php
mydomain.tld/cateogry/blue.html --> mydomain.tld/index.php?category=blue
mydomain.tld/type/b.html --> mydomain.tld/index.php?type=b

The following seems to work, but I am unable to get any variables from the URL ($_GET["category"] for example).

RewriteEngine on
RewriteRule ^type/([^/]*)\.html$ index.php?type=$1 [L]
RewriteRule ^category/([^/]*)\.html$ index.php?category=$1 [L]
#RewriteRule ^(.*)\.html $1\.php

Where am I going wrong?

Karma

4:00 pm on Aug 16, 2011 (gmt 0)

10+ Year Member



Please ignore, I had a problem with my PHP code.

g1smd

7:00 pm on Aug 16, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have some problems with your code.

^type/([^/]*)\.html$
- allows
example.com/type/.html
to be a valid URL request.

You need
+
in place of
*
here and in all similar patterns.