Server 500 errors every time

New to mod_rewrite? This is a good place to start.

Server 500 errors every time

Postby skygod12000 » Wed Aug 05, 2009 3:31 am

This is driving me insane and after two virtually sleepless nights peering at my screen, I have to accept personal defeat and request assistance.

I migrated our data from a flat form database to a relational database at the weekend, however we have mailed out many links to individual properties in the past which we would like the recipients to still be able to follow.

I have kept the primary ids and references the same in order to enable the rewrite, but just keep getting Internal Server 500 errors for all attempts at writing the RewriteRule.

The syntax of the old links were as follows

http://webserver/detail.php?prop_id=HR1273
http://webserver/detail.php?listing_id=33243

These need to be redirected to

http://webserver/?p=detail&ref=HR1273
http://webserver/?p=detail&id=33243


I would be very appreciative of assistance in resolving this, as management are getting pissed off at my inability to deliver a solution.


George
skygod12000
 
Posts: 8
Joined: Wed Aug 05, 2009 3:13 am

Postby richardk » Wed Aug 05, 2009 3:41 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.*&)?prop_id=([^&]+)(&.*)?$ [NC]
RewriteRule ^detail\.php$ /?p=detail&ref=%2 [R=301,L]

RewriteCond %{QUERY_STRING} ^(.*&)?listing_id=([^&]+)(&.*)?$ [NC]
RewriteRule ^detail\.php$ /?p=detail&id=%2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Many Thanks

Postby skygod12000 » Sat Sep 05, 2009 6:43 am

Richard,

You are a star! Saved my bacon and all the old links are passed through correctly now.

I am very impressed with your knowledge and understanding of how mod_rewrite works. I just keep getting it 'wrong' and generate 500 server errors. (One day maybe I'll 'get it' )
skygod12000
 
Posts: 8
Joined: Wed Aug 05, 2009 3:13 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 26 guests

cron