Home > Backend Development > PHP Tutorial > How to change the user's access to abc.com to www.abc.com so that it does not cross domains (what do cname, explicit URL, and implicit URL mean)

How to change the user's access to abc.com to www.abc.com so that it does not cross domains (what do cname, explicit URL, and implicit URL mean)

WBOY
Release: 2023-03-01 15:54:01
Original
4998 people have browsed it

The situation we encountered is this: if the user enters abc.com, but our server is actually at www.abc.com, a cross-domain error will occur.
I saw that JD.com will automatically change the address to www. For example, if JD.com enters jd.com, the address displayed by the browser will automatically become www.jd.com. How is this done?

I only know about domain name resolution, but I want to say that there are three types of domain name resolution in Alibaba Cloud that seem to be able to do it: cname, explicit URL, and implicit URL. Which one should it be? And what are the differences between these three.

In addition, we also have a domain name cde.com, which has been abandoned due to historical reasons, but we want users to jump to www.abc.com when they visit cde.com. What should we do?

Reply content:

The situation we encountered is this: if the user enters abc.com, but our server is actually at www.abc.com, a cross-domain error will occur.
I saw that JD.com will automatically change the address to www. For example, if JD.com enters jd.com, the address displayed by the browser will automatically become www.jd.com. How is this done?

I only know about domain name resolution, but I want to say that there are three types of domain name resolution in Alibaba Cloud that seem to be able to do it: cname, explicit URL, and implicit URL. Which one should it be? And what are the differences between these three.

In addition, we also have a domain name cde.com, which has been abandoned due to historical reasons, but we want users to jump to www.abc.com when they visit cde.com. What should we do?

Make a 301 jump on the web server, nginx example:

<code class="nginx">server {
    listen 80;
    server_name abc.com cde.com;
    location / {
        return 301 http://www.abc.com$request_uri;
    }
}</code>
Copy after login

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://yoururl/");

php code implementation

Do you know 301 permanent redirection? This is to solve the user access problem. cname is the ip resolved by address B and is provided to address a for redirected access.
The explicit URL means that the address bar will become invisible when jumping. The URL is the address bar when jumping. The address is still a.b.c. The way to do this is actually the iframe framework

Set up 301 redirect

Use 301 permanent redirect which is friendly to crawlers

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template