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.