DedeCMS 301 redirection configuration method

Source: Internet
Author: User

I. How to set 301 redirection in Linux

1. Create a notepad document, click "file" -- "save as", select "all files" for "Save type", and the file name is. you can use htaccess without forcing the input file name.

2. Open the newly created. htaccess file in Notepad and copy the following code.

Go in

The code is as follows: Copy code

Options + FollowSymLinks
RewriteEngine on
Rewritecond % {http_host} ^ 111cn [nc]
Rewriterule ^ (. *) $ http: // www.111cn/$1 [r = 301, nc]

3. Replace the URL with your URL, and then save and upload the root directory of your website. At this time, you will find that entering the root domain name in your IE address bar will jump to the www domain name.

II. How to set 301 redirection in Windows and remove html

Replace the following code with the index. php file in the root directory.

The code is as follows: Copy code

<? Php
$ HOST = $ _ SERVER ['http _ host'];
If ($ HOST = "429006.com" | $ HOST = www.111cn.net "{
Header ("HTTP/1.1 301 Moved Permanently ");
Header ("Location: http://www.429006.com ");
Exit ();
}
If (! File_exists (dirname (_ FILE _). '/data/common. inc. Php '))
{
Header ('Location: install/index. Php ');
Exit ();
}
Require_once (dirname (_ FILE _). "/include/common. inc. php ");
Require_once DEDEINC. "/arc. partview. class. php"; $ GLOBALS ['_ arclistEnv'] = 'index ';
$ Row = $ dsql-> GetOne ("Select * From 'dede _ homepageset '");
$ Row ['templet'] = MfTemplet ($ row ['templet']);
$ Pv = new PartView ();
$ Pv-> SetTemplet ($ pai_basedir. $ pai_templets_dir ."/".
$ Row ['templet']);
$ Pv-> Display ();
?>

Or use the following code:

<? Php
$ Jump301 = 1; // whether to enable the 301 jump switch, 1 on 0 off
Using index_file='index.html '; // The homepage file does not support SSI (shtml/shtm)
If (substr ($ _ SERVER ['server _ name'], 0, 4 )! = 'Www. '& $ jump301)
{
Header ('http/1.1 301 Moved Permanently ');
Header ('Location: http: // www. '. $ _ SERVER ['server _ name']);
Exit ();
}
If (! File_exists (dirname (_ FILE _). '/data/common. inc. Php '))
{
Header ('Location: install/index. Php ');
Exit ();
}
// Automatically generate the HTML version
If (isset ($ _ GET ['pcache'])
{
Require_once (dirname (_ FILE _). "/include/common. inc. php ");
Require_once DEDEINC. "/arc. partview. class. php ";
$ GLOBALS ['_ arclistenv'] = 'index ';
$ Row = $ dsql-> GetOne ("Select * From '#@__ homepageset '");
$ Row ['templet'] = MfTemplet ($ row ['templet']);
$ Pv = new PartView ();
$ Pv-> SetTemplet ($ pai_basedir. $ pai_templets_dir. "/". $ row ['templet']);
$ Pv-> SaveToHtml (dirname (_ FILE _). '/'. $ index_file );
Include (dirname (_ FILE _). '/'. $ index_file );
Exit ();
}
Include (dirname (_ FILE _). '/'. $ index_file );
?>

Summary

In fact, the simplest way is to make 301 on the server, which is much better than modifying the code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.