Page 1 of 1

Mod Rewrite not working

Posted: Mon Jan 22, 2007 11:48 am
by psurrena
I'm just started playing with mod_rewrite and have not been able to get this working.

The URL to be rewritten is: http://www.enumerated.org/view.php?cat=turtle&id=11

My .htaccess file is:

Code: Select all

RewriteEngine On
RewriteRule ^([^-]*)-([^-]*)\$&html$ /view.php?cat=$1&id=$2 [L]
This should produce: http://www.enumerated.org/turtle/11.html

Is there any additonal code needed in the .htaccess file?

Thank you in advance.

-Pete

Posted: Mon Jan 22, 2007 12:01 pm
by feyd
There are no dashes or "$&html" contained in your url's... I'm totally confused.

Posted: Mon Jan 22, 2007 12:09 pm
by psurrena
The code was generated from a this site: http://www.mod-rewrite-wizard.com/

Posted: Mon Jan 22, 2007 12:13 pm
by feyd
That site generated

Code: Select all

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /view.php?cat=$1&id=$2 [L]
when I pasted your original.

Posted: Mon Jan 22, 2007 12:15 pm
by psurrena
Odd, I pasted what what was infront of me.

Maybe I should just avoid that website ;)

Posted: Mon Jan 22, 2007 1:10 pm
by psurrena
I just wrote my own regex

Code: Select all

RewriteEngine On
RewriteRule ^view/([0-9])+)?$ view.php?id=$1 [L]
It doesn't work but I don't see why not...

Posted: Mon Jan 22, 2007 2:02 pm
by feyd
Count your parentheses.

Posted: Mon Jan 22, 2007 4:23 pm
by psurrena
Got it thanks but still not working...

I simplied my URL: http://www.enumerated.org/view.php?id=3

my code is

Code: Select all

RewriteEngine On
RewriteRule ^view/([0-9]+)?$ view.php?id=$1 [L]
When I enter the URL into the address bar it should change to http://www.enumerated.org/view/3, right?
Right now, nothing at all happpens

Posted: Mon Jan 22, 2007 8:32 pm
by feyd
You're thinking the wrong direction.

http://www.enumerated.org/view/3 is translated to http://www.enumerated.org/view.php?id=3 if it is functioning correctly.