Solution to the DiscuzX3.n series Domain Name Redirection problem, discuzx3.n Domain Name Redirection

Source: Internet
Author: User
Tags net domain url forwarding

Solution to the DiscuzX3.n series Domain Name Redirection problem, discuzx3.n Domain Name Redirection

For various reasons, the original use of http://bbs.lgms.net domain names need to switch to the http://www.szlgcn.com domain name.

I wrote a 301. inc. php file to Reference Forum program files as needed.

301. inc. php file content:

<? Php

$ The_host = $ _ SERVER ['HTTP _ host']; // obtain the current access domain name
$ Url = $ _ SERVER ['php _ SELF ']; // The string after the domain name is obtained, for example,/bbs/index. PHP
$ Filename = substr ($ url, strrpos ($ url, '/') + 1); // extract the current file name
$ Querystring = $ _ SERVER ['query _ string']; // obtain the parameters following the question mark
// Echo 'location = '. $ the_host.'/'. $ filename .'? '. $ Querystring; // used for testing. See the obtained link.
If ($ the_host! = 'Www .szlgcn.com ') // verify the current access domain name (your new domain name): If the domain name is not enclosed in quotation marks, perform the following jump --
{
If ($ querystring! = '') // Verify whether a parameter exists after the file name. If a parameter exists, it is redirected --
{
Echo '<script language = "javascript"> ';
Echo 'location = "http://www.szlgcn.com/'.?filename .'? '. $ Querystring .'"';
Echo '</script> ';
}
Elseif ($ filename = 'index. php') // directly jump to the new domain name if it is the Home Page
{
Echo '<script language = "javascript"> ';
Echo 'location = "http://www.szlgcn.com /"';
Echo '</script> ';
}
Else // jump to -- if no parameter exists --
{
Echo '<script language = "javascript"> ';
Echo 'location = "http://www.szlgcn.com/'.w.filename .'"';
Echo '</script> ';
}
}

?>

Reference in a program file that may involve redirection, such as forum. php. the reference method is "<? Insert the second line below php:

Include ('1970. inc. php ');

The result is similar to the following:

<? Php
Include ('1970. inc. php'); // 301 redirection

// Other codes

?>


OK.

Note: The above "program files involving redirection" may be available in DZ X3.n:

Search. php, portal. php, home. php, group. php. For example: http://bbs.lgms.net/forum.php? Mod = viewthread & tid = 16787.

Note: If you want to modify plugin. php, index. php, and member. php, you still need to fine-tune the relevant programs.


The preceding solutions are complex and may lead to unexpected problems, such as the image may not be displayed during upload.

Is there a better solution? Yes!

That is, use the Apache configuration file and use the IfModule mod_rewrite.c configuration section to perform Domain Name Redirection.

1. Use ps-aux to view all processes and find the directory where the WEB Service is located.

2. Find the httpd. conf file in the directory where Apache is located.

3. Modify httpd. conf:

(1) Ensure that LoadModule rewrite_module modules/mod_rewrite.so is valid (if there is # above, remove #);

(2) Modify ServerName localhost: 80, ServerAdmin yourQQNo@qq.com (selected );

(3) modify the AllowOverride of the Options FollowSymLinks directory to All (generally None ).

(4) Add the <IfModule mod_rewrite.c> section with the following content:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond % {HTTP_HOST} ^ bbs.lgms.net [NC]
RewriteRule ^ (. *) $ http://www.szlgcn.com/#1 [R = 301, L]
RewriteCond % {HTTP_HOST} ^ s.lgms.net [NC]
RewriteRule ^ (. *) $ http://www.szlgcn.com/#1 [R = 301, L]
</IfModule>

Note: Replace the domain name with your own domain name in the relevant location or switch to the replacement URL.

4. Restart Apache after modification. Command: service httpd restart.

OK. The test is successful.


Domain Name Redirection

It is easy to handle your problems.
Generally, free space does not support domain name binding, so direct binding is not possible. What meets your requirements is URL forwarding, that is, Domain Name Redirection!
For example, if the second-level domain name address provided by your free space is top.admin5.com and your domain name is cnbeg.com, you only need to log on to your cnbeg.com domain name management and set URL forwarding, you can enter WWW in the Host header and forward it to top.admin5.com!
Hope to solve it as soon as possible!

Help

.... I have done it before, but I am not clear about it. Let's talk about my ideas. First, create a website with a top-level domain name, then set it on the website in the jump mode, and set the jump in seconds, I don't know the code. If the people below know it, paste it and I don't matter if I give it to him.

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.