-1

I want to create a clean url for my blog.php page I dont want to show the blog.php in address bar I want this type of url

http://www.webiste.com/title/how-to-make-dynamic-menu

But my existing url is like that

http://www.webiste.com/blog.php?title=how-to-make-dynamic-menu

I have read and attempt many code but didn't get the good result

Amit Verma
  • 38,175
  • 19
  • 80
  • 104

1 Answers1

0

Here is what you should write

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/+blog\.php\?title=([^\s&]+) [NC]
RewriteRule ^ blog/%1? [R=301,L]

RewriteRule ^blog/([^/]+)/?$ blog.php?title=$1 [L,QSA]

I guess i should explain what does this peace of code do. Its a basic "if" statement.

You see mod_rewrite or "RewriteEngine" give us the option to take the original query, and if it matches a certain criteria (RewriteCond ) rewrite it to something else (RewriteRule).

thefolenangel
  • 740
  • 5
  • 24
  • i m using on localhost my folder name is testing and for testing i m using now static way below Titanic but now didn't worked yes i also create a .htaccess file copy and paste the code which you provide – amarjeet singh Apr 13 '18 at 06:51