Jump to content

How to make my links url rewrite in htaccess work?


InvestLearn

Recommended Posts

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>
 
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.