Wednesday, August 6, 2008

URL redirect

Redirect Directive

Description: Sends an external redirect asking the client to fetch a different URL
Syntax: Redirect [status] URL-path URL
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_alias

The Redirect directive maps an old URL into a new one by asking the client to refetch the resource at the new location.

The old URL-path is a case-sensitive (%-decoded) path beginning with a slash. A relative path is not allowed. The new URL should be an absolute URL beginning with a scheme and hostname.


vi /etc/apache2/apache2.conf

RewriteEngine on
Redirect /service

If the client requests http://myserver/service/foo.txt, it will be told to access instead.

Meta Refresh URL Redirect

Meta Refresh URL Redirect is an example of a meta refresh URL redirect.
The code is,

< meta http-equiv="refresh" content="5;url=" />

This method displays the new page that the refresh points to by 5 seonds.

PHP URL Redirect

The code for redirect URL, code goes at the top of the page.

No comments: