Davie33 Posted June 22, 2012 Share Posted June 22, 2012 Hi how do i make the rule for htaccess file for this code i have ?. so it can show like this.... http://localhost/template/cats/CPUs%20-%20Processors/1.html I have this but doesnt seem to do the trick. RewriteRule page-(.*)\.html$ index.php?act=$1&id&page=$2 <?php $query = mysql_query("SELECT * FROM cats WHERE id ORDER BY catname ASC LIMIT 15") or die(mysql_error()); while ($row = mysql_fetch_assoc($query)) { echo '<a href="' . $urlpath . 'cats/' . $row['catname'] .'/1.html">' . $row['catname'] . '</a> / '; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/264623-htaccess-help-needed/ Share on other sites More sharing options...
requinix Posted June 22, 2012 Share Posted June 22, 2012 I have this but doesnt seem to do the trick. RewriteRule page-(.*)\.html$ index.php?act=$1&id&page=$2 Well yeah: that URL doesn't match up with what you're trying to use. ^cats/([^/]+)/(\d+)\.html$ (assuming this will go in /template/.htaccess) Quote Link to comment https://forums.phpfreaks.com/topic/264623-htaccess-help-needed/#findComment-1356206 Share on other sites More sharing options...
Davie33 Posted June 22, 2012 Author Share Posted June 22, 2012 Hi am not getting the page to show what am i doing wrong ?. He is the rule RewriteRule "^cats/([^/]+)/(\d+)\.html$" Quote Link to comment https://forums.phpfreaks.com/topic/264623-htaccess-help-needed/#findComment-1356227 Share on other sites More sharing options...
requinix Posted June 22, 2012 Share Posted June 22, 2012 What you're doing wrong is just throwing stuff into your .htaccess without actually knowing what you're doing. mod_rewrite Quote Link to comment https://forums.phpfreaks.com/topic/264623-htaccess-help-needed/#findComment-1356266 Share on other sites More sharing options...
Davie33 Posted June 24, 2012 Author Share Posted June 24, 2012 Yeah your right i don't know much about htaccess mod rewrite which i am reading up on. This is my full rule which works apart from the 2nd one that only shows id and not catname. Rewrite Rule ^cats/([^/]+)/(\d+)\.html$ index.php?act=cats&id=$1&page=$2 For the rule you gave me does work but not on its own so i added the 2nd part of the rewrite rule and works. When i tryed your rule like this RewriteRule ^cats/([^/]+)/(\d+)\.html$ was getting error that's why i tryed with adding "" and it stopped the error but still didn't show the cat page so thats why i added the 2nd part of the rewrite rule. So i would just like to thank you for the help thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/264623-htaccess-help-needed/#findComment-1356600 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.