php htaccess redirect rewriterule parameters





php htaccess redirect


Htaccess redirect

Learn php htaccess redirect rewriterule flags , syntax using the sample example below.

Redirects with Server Side Scripting

If you have a dynamically driven (server side) web site, you can implement one or more of the following scripts, depending on which scripting language(s) you use.
These portions of code are fairly self-explanatory. They simply provide the appropriate 301 response header, and the location of the new page.

HTTP 301 Redirect in ASP-VBScript

Include the following ASP code at the top of each page:
<%@ Language=VBScript %>
<%
' Permanent redirection
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.dexterityunlimited.com/"
Response.End
%>

HTTP 301 Redirect in ColdFusion

Include the following ColdFusion code at the top of each page:
<CFHEADER statuscode="301" statustext="Moved Permanently">
<CFHEADER name="Location" value="http://www.dexterityunlimited.com/">

HTTP 301 Redirect in PHP

Include the following PHP code at the top of each page:
<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.dexterityunlimited.com/");
exit();
?>

HTTP 301 Redirect in Perl

Include the following Perl code at the top of each page:
#!/usr/bin/perl -w
use strict;
print "Status: 301 Moved Permanently\n";
print "Location: http://somewhere/page.htm\n\n";
exit;

HTTP 301 Redirect in JSP/Java

Include the following Java code at the top of each page:
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.dexterityunlimited.com/" );
response.setHeader( "Connection", "close" );
%>

Redirecting with .htaccess

If you are on an Linux/Apache server, or a Microsoft Windows Server that can run Apache modules, you can do your redirects with an .htaccess file.
The .htaccess file is a very powerful tool, but can wreak havoc on a site if not implemented correctly. Always save a backup of any existing .htaccess file before attempting any changes.

Redirection with mod_rewrite

The following lines redirect the client to a new location. In this case, a request for the file contact.php is sent to the file contact-us.php:
rewriteEngine on
rewriteRule ^contact\.php$ http://www.dexterityunlimited.com/contact-us.php [R=permanent,L]


php htaccess redirect syntax

php htaccess redirect code on this is provided for your study purpose, it will guide you to know how to use mod_rewite to create .htaccess files on the apache servers. use it to practice and train your self online

All the tutorials on this site are free, the page code is provifed for you to use it to practice, if you want to help to improve and maintain this work, you can donate to us on.



Htacess tutorial guides withexamples and easy steps to set ip up on your server.


Htaccess Generator

Htaccess block all bad robots

prevent hack

redirect www to non www

modifying the environment variable

file access deny control

cache control no cache and cache public

ip blocking

adding new mime types and set timezone

hot to create file

hide .

gzip page compression

force file save

password protect a directory

hotlink protection

custom error page

stop directory listing

block and allow referrer

set cookie domain authentication

prevent directory listing

php 301 redirect

upload_max_filesize limit

301 redirect

changing home directory page

All the tutorials on this site are provided for free. You can copy and print the tutorials and code on this site, but you are not allowed to reproduce this information on another website. All rights reserverd 2012

Copywright © 2013 www.htaccessredirect301.com Site created By prince Ejike Google+

promo