Hello,
How do I redirect "example.com/blogs" to "example.com/blogs.php"
Thanks in advance,
John
Hello,
How do I redirect "example.com/blogs" to "example.com/blogs.php"
Thanks in advance,
John
It looks like you want to rewrite the URL. This is not for the faint of heart but if you want to do it then you should check out a tutorial on URL rewriting.
In your .htaccess file:
RewriteEngine On
RewriteRule ^blogs /blogs.php [R=301,L]
If you are using Apache, the easiest thing to do is to enable the MultiViews
option in your httpd.conf
file (to enable it globally) or in a .htaccess
file (to enable it per-directory).
The effect of
MultiViews
is as follows: if the server receives a request for/some/dir/foo
, if/some/dir
hasMultiViews
enabled, and/some/dir/foo
does not exist, then the server reads the directory looking for files namedfoo.*
, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements.
Translation into English: it will see blogs
doesn't exist, but blogs.php
does, so it will load blogs.php
.
You could be a total cheater and make a directory "/blogs" and inside blogs have a file index.php, and in index.php write:
<?
header("Location: ../blogs.php");
?>
Which just redirects to the correct page... This is just an alternate suggestion to the much better suggestions above... :)
<html>
<head>
<title>redirect</title>
<META http-equiv="refresh" content="5;URL=http://www.example.com/blogs.php">
</head>
</html>