How to create clean url using .htaccess
Solution 1
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]
Solution 2
If you're want to have clean URLs, then you have to use clean URLs in your html code, e.g. use
<a href="/movie/titanic">Titanic</a>
Your rewrite rules will take that doesn't-really-exist-on-the-server address (you don't really have a /movie
directory that contains a titanic
file, after all), and translates it in to the actual
/movie.php?name=titanic
The user would never see this url, however, because the rewrite would take place purely within Apache. As long as the HTML you send to the user contains only "clean" urls, they'll never see the query strings.
Solution 3
RewriteEngine on
RewriteRule ^movie/([0-9a-zA-Z]+)$ movie.php?name=$1 [L]
Add above code in .htaccess file
Comments
-
Rakesh almost 2 years
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