stig1 Posted November 10, 2010 Share Posted November 10, 2010 I have the current rule in my htaccess RewriteRule ^catalogue/([a-z0-9-]+)/([a-z0-9-]+).php$ catalogue/item.php?id1=$1&id2=$2 [L] however whenever i type in the browser /catalogue/computers/cases.php and then change the category to a category not in my database it still shows the item.php page but without any data - blank page. How do you redirect this to a 404 or do I just write a script that if no records are found in the database redirect to the main catalogue page? Quote Link to comment https://forums.phpfreaks.com/topic/218329-htaccess-querystring/ Share on other sites More sharing options...
trq Posted November 10, 2010 Share Posted November 10, 2010 You should check your query actually found a result using mysql_num_rows. Quote Link to comment https://forums.phpfreaks.com/topic/218329-htaccess-querystring/#findComment-1132798 Share on other sites More sharing options...
stig1 Posted November 10, 2010 Author Share Posted November 10, 2010 I didnt know if htaccess would do it, cause i know i can do it the other way, just thought there might have been an easier way, instead of doing a mysql_num_rows query. thanks! Quote Link to comment https://forums.phpfreaks.com/topic/218329-htaccess-querystring/#findComment-1132802 Share on other sites More sharing options...
trq Posted November 10, 2010 Share Posted November 10, 2010 That would mean that mod_rewrite would need to check for the existence of a record within your database, that's what PHP is for. Quote Link to comment https://forums.phpfreaks.com/topic/218329-htaccess-querystring/#findComment-1132818 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.