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 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 301 Redirect in PHP

Include the following PHP code at the top of each page:
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");

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";

HTTP 301 Redirect in JSP/Java

Include the following Java code at the top of each page:
response.setHeader( "Location", "" );
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$ [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 ads

gzip page compression

301 redirect

adding new mime types and set timezone

block all bad robots

block and allow referrer

cache control no cache and cache public

php 301 redirect

changing home directory page

custom error page

file access deny control

force file save

hide .

hot to create file

hotlink protection

ip blocking

modifying the environment variable

password protect a directory

prevent directory listing

prevent hack

redirect www to non www

set cookie domain authentication

stop directory listing

upload_max_filesize limit

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 Site created By prince Ejike Google+