Permalinks using htaccess

Ive been reading rewrite but cant get my head around it so i need help please. i am currently running this on my localhost

My current url reads websites/aislingmcateer.com/videos.html?id=1
however i want it to read

websites/aislingmcateer.com/videos/video-id-permalink.html

When a video iss added the title is turned into a permalink so My Lovely Horse becomes my-lovely-horse

code for link is
if(mysql_num_rows($result) == 0){
echo “NO VIDEOS ADDED YET”;
}else{
while($video = mysql_fetch_array($result)){
$id = $video[‘id’];
$title = $video[‘title’];
$op = “~ <a href=\“videos.html?id=$id\”>$title</a><br />”; <—LINK OUTPUT HERE
}
echo $op;
}

and to display video is
$id = $_GET[‘id’];
if(isset($id)){
$sql = "SELECT * FROM amc_videos ";
$sql .= “WHERE id = $id AND hide = 0”;
}
while ($row = mysql_fetch_array($result)){
$title = $row[‘title’];
$permalink = $row[‘permalink’];
$video .= str_ireplace(“allowfullscreen”, “”, “{$row[‘embed’]}”);
$op .= “<h2>$title</h2><br />”;
$op .= “$video”;
}

im assuming permalink needs to be assigned to work in the htaccess
So how can i get the permalink displayed

htaccess so far

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^(.*)\.html $1\.php

So you want for example /video-5-my-beautiful-horse.html ?

If so, try this:


Options +FollowSymlinks -Indexes -MultiViews

RewriteEngine On
RewriteRule ^video-([0-9]+) videos.html?id=$1

Although that videos.html is probably a rewrite of it’s own to a .php or something isn’t it? If so, replace videos.html with whatever file is actually serving up that “file” :slight_smile: