tags:

views:

120

answers:

5

Hello,

How do I redirect "example.com/blogs" to "example.com/blogs.php"

Thanks in advance,

John

+1  A: 

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.

Andrew Hare
+5  A: 

In your .htaccess file:

RewriteEngine On
RewriteRule ^blogs /blogs.php [R=301,L]
MiffTheFox
Hmm. I tried this and it's not working. It gives me a 404 if I type in example.com/blogs.I wonder if I changed the .htaccess file correctly.
+2  A: 

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 has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, 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.

John Kugelman
A: 

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... :)

micmoo
A: 
<html>
<head>
<title>redirect</title>

<META http-equiv="refresh" content="5;URL=http://www.example.com/blogs.php"&gt;

</head>

</html>
natas