Jump to content

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>
 

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.