wordpress - 如何设置子域以在我的网站中显示静态页面?
问题描述
我在 Vultr 中添加了名称服务器。
我希望它在我使用该名称服务器时加载一个页面
edu.mrtrobotics.com -----> mrtrootics.com/page
我正在使用 wordpress 和 nginx。我应该怎么办??当用户使用子域时,我是否必须更改 nginx 中的某些内容才能重定向到特定页面?还是在 DNS 中声明???我一点头绪都没有。。
server {
listen 80;
listen [::]:80;
server_name mrtrobotics.com www.mrtrobotics.com;
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/html;
}
location / {
rewrite ^ https://$host$request_uri? permanent;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mrtrobotics.com www.mrtrobotics.com;
index index.php index.html index.htm;
root /var/www/html;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/mrtrobotics.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mrtrobotics.com/privkey.pem;
include /etc/nginx/conf.d/options-ssl-nginx.conf;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
# enable strict transport security only if you understand the implications
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off; access_log off;
}
location = /robots.txt {
log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}
# Set client upload size - 100Mbyte
client_max_body_size 100M;
# to avoid 504 time out error - defalut is 60s
proxy_send_timeout 180s;
proxy_read_timeout 180s;
fastcgi_send_timeout 180s;
fastcgi_read_timeout 180s;
解决方案
那是在nginx配置中。您需要添加以下内容(假设您的证书适用于edu.
您的主域):
server {
listen 80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name edu.mrtrobotics.com;
ssl_certificate /etc/letsencrypt/live/mrtrobotics.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mrtrobotics.com/privkey.pem;
include /etc/nginx/conf.d/options-ssl-nginx.conf;
rewrite ^ https://mtrobotics.com/some-page permanent;
}
这应该将任何请求edu.mtrobotics.com
(使用任何路径或参数)重定向到https://mtrobotics.com/som-page
.
推荐阅读
- php - CakePHP 迁移 3.9 到 4.2 未定义方法 Cake\Core\Plugin::load()
- javascript - 使用 Javascript 将图像添加到产品中
- nginx - Nginx 报“上游连接超时”
- sql - SQL 如果存在则“是”否则“否”在新列中
- mysql - mySQL 8 存储过程错误代码:1241。操作数应包含 1 列
- javascript - MongoDB 格式化时间戳以显示“多久以前”文本
- c++ - C++:为什么我不能用相对路径打开文件?
- java - Java - 拼接字符串[]
- python-3.x - 如何使用 Python 3.x 在命令行中执行多个命令
- ruby-on-rails - 为谷歌凭据设置配置变量并使用 elishaterada/heroku-google-application-credentials-buildpack 后仍然出现错误