Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove id and title from this url? [duplicate]

I need to remove ?id= and &title= from this url using .htaccess file.

URL now - http://www.XXXX.com/video.php?id=XX&title=XXX-XXX-XXX

What I need - http://www.XXXX.com/video.php/XX/XXX-XXX-XXX

I already have removed .php from all links.

like image 232
Nilohn Avatar asked Apr 21 '15 07:04

Nilohn


2 Answers

Following htaccess code will do your work

    //First Parameer
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ video.php?id=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ video.php?id=$1

    //Second Parameter
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ video.php?id=$1&title=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ video.php?id=$1&title=$2
like image 66
Subodh Ghulaxe Avatar answered Sep 25 '22 16:09

Subodh Ghulaxe


add below code to your .htaccess file.

RewriteEngine on
RewriteBase / 
RewriteCond %{QUERY_STRING} ^id=(.*)\&title=(.*)
RewriteRule (.*) /$1/%1/%2?  [NC,L,R=301]

output is

http://www.XXXX.com/video.php/XX/XXX-XXX-XXX

this code is working for me i hope it is working for you.

like image 29
Renish Khunt Avatar answered Sep 26 '22 16:09

Renish Khunt