Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create clean url using .htaccess

This is my .htaaccess code.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/$ movie.php?name=$1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example\.in$
RewriteRule ^/?$ "http\:\/\/example\.in" [R=301,L]
ErrorDocument 404 /404.php
AddDefaultCharset UTF-8
Header unset ETag
FileETag None

I need clean url for my website. I've referred lots of tutorials and forums and created the above code. But not working.. Almost I'm fighting with code. I dont understand the clean url concept clearly. Is there any codings I ve to write on my php page.

<a href='movie.php?name=titanic'> Titanic </a>

I've this link in my index.php file.

I want example.in/movie/titanic while click the link Titanic.

Also I want to get the value by $_[request].

What exactly I've to do. Please dont make this question as duplicate, I've searched a lot and didn't got the concept clearly. Please help me out.

Thanks

like image 633
Rakesh Avatar asked Dec 25 '22 20:12

Rakesh


1 Answers

Replace your code with this:

ErrorDocument 404 /404.php
AddDefaultCharset UTF-8
Header unset ETag
FileETag None

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+movie\.php\?name=([^\s&]+) [NC]
RewriteRule ^ movie/%1? [R=301,L]

RewriteRule ^movie/([^/]+)/?$ movie.php?name=$1 [L,QSA]
like image 77
anubhava Avatar answered Dec 28 '22 09:12

anubhava