Mod Rewrite not working

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Mod Rewrite not working

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There are no dashes or "$&html" contained in your url's... I'm totally confused.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Post by psurrena »

The code was generated from a this site: http://www.mod-rewrite-wizard.com/
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That site generated

Code: Select all

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /view.php?cat=$1&id=$2 [L]
when I pasted your original.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Post by psurrena »

Odd, I pasted what what was infront of me.

Maybe I should just avoid that website ;)
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Count your parentheses.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply