.htaccess code not working on new server

Discuss practical ways rearrange URLs using mod_rewrite.

.htaccess code not working on new server

Postby stevesimo » Thu May 07, 2009 2:40 am

Hi, I have just changed my hosting from a Windows VPS to a dedicated server running Linux. The sites which use mod rewrite are not working and I dont know what is wrong with the syntax. Mod Rewrite has definitely been enabled on the server. I am trying to get an rewritten url with 3 variables to redirect to a script called viewproducts.php. Here is my code:

So that the url:
viewproducts-producttitle-productname-id-123-cat-categoryname.htm

Will redirect to:
viewproducts.php?producttitle=productname&id=123&cat=categoryname

Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule viewproducts-producttitle-(.*)-id-(.*)-cat-(.*)\.htm$ viewproducts.php?producttitle=$1&id=$2&cat=$3


Can anyone point out what is wrong with this as it worked fine on my previous server.

Thanks, Steve
stevesimo
 
Posts: 1
Joined: Thu May 07, 2009 2:31 am

Postby richardk » Thu May 07, 2009 1:52 pm

What happens?

Mod Rewrite has definitely been enabled on the server.

Does this mod_rewrite test work?

Try
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^viewproducts-producttitle-([^/]+)-id-([0-9]+)-cat-([^/]+)\.htm$ /viewproducts.php?producttitle=$1&id=$2&cat=$3 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 17 guests

cron