InvestLearn Posted November 22, 2018 Share Posted November 22, 2018 Hi Everybody, I am working a personal blog and i am trying to make links rewrtie in htaccess, but having difficult time, i have googled but the solution propose don’t work for me, so i am posting to have some help on this. I am testing the links rewrite on localserver wamp. I want to rewrite to 3 majors links but only got one worked. The others Two, can’t sort out, here my code. HEADER.HTML : <a class="nav-link" href="http://localhost/bourseconseils/browse.php?categorie=<?php echo urlencode($row['cat_name']);?>"> <?php echo htmlout(strtoupper(str_replace('_',' ', $row['cat_name'])) );?> POSTS.HTML <a href="http://localhost/bourseconseils/details.php?postid=<?php echo $row['article_id']; ?>" class="btn btn-primary">Lire plus →</a> THE RESULT I AM LOOKING FROM : browse.php?categorie=test to browse/test FROM : details.php?postid=1 to details/1 HERE IS MY HTACCESS <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine on RewriteRule ^browse/([a-zA-Z0-9-=_?]+)/?$ browse.php?categorie=$1 [L] #FOR ADMIN RewriteRule ^admin/homeadmin?$ admin/homeadmin.html RewriteRule ^details/(.*)$ /details.php?postid=$1 </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/307933-how-to-make-my-links-url-rewrite-in-htaccess-work/ Share on other sites More sharing options...
requinix Posted November 22, 2018 Share Posted November 22, 2018 You're thinking about this backwards. You have to rewrite from the URL you want to see in the browser to the URL that actually works with your scripts. So that's from /browse/test to /browse.php?catergorie=test, and from /details/1 to /details.php?postid=1. That also means all the URLs you generate need to be the ones you want to see. No, they will not be fixed for you, you have to do it. Quote Link to comment https://forums.phpfreaks.com/topic/307933-how-to-make-my-links-url-rewrite-in-htaccess-work/#findComment-1562380 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.