这是我的 vhost.conf
<VirtualHost *:80>
<files xmlrpc.php>
order allow,deny
deny from all
</files>
ServerName www.myserver.com
ServerAlias myserver.com
DocumentRoot /var/www/vhosts/www.myserver.com
<Directory /var/www/vhosts/www.myserver.com>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
# AllowOverride None
#Order Allow,Deny
#Allow from All
#Deny from 124.43.19.230
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# Restrict access to PHP files from plugin and theme directories
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
</IfModule>
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/
RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L]
RewriteCond %{REQUEST_URI} !^/wp-content/themes/file/to/exclude\.php
RewriteCond %{REQUEST_URI} !^/wp-content/themes/directory/to/exclude/
RewriteRule wp-content/themes/(.*\.php)$ - [R=404,L]
</Directory>
</VirtualHost>
在浏览器中输入 www.myserver.com 时,它会转到我的根目录并获取 index.php
但是当我输入 myserver.com 时,它会转到默认的 Apache 网页(index.html)加载
所以我添加这一行进行重写
</VirtualHost>
<VirtualHost *:80>
ServerName myswever.com
ServerAlias *.myswever.com
Redirect permanent / https://www.myswever.com/
</VirtualHost>
但它不起作用它是一个word-press网站如何重新连接url
当某些类型 myswever.com 它应该加载 www.myswever.com
这可能只是一个错字吗?
我的swever?
否则检查是否有其他配置处于活动状态,使用
停用
还要检查是否有另一个配置在下面创建这个
顺便说一句,您的 vhost.conf 用于端口 80,它是纯 HTTP,您的重定向转到 HTTPS,端口 443。如果您不激活 mod_ssl 并为端口 443 添加/扩展 vhost 配置,则 https 重定向将不起作用。
您的标准 apache 页面建议您仍然有一个活动的默认配置,您可以将其删除,它应该在文件夹中
/etc/apache2/sites-available/*
,如果它是活动的,那么将有一个指向/etc/apache2/sites-enabled/*
此配置的符号链接。上面的两个命令都显示了所有活动或非活动配置,它们将简单地删除此配置的符号链接/etc/apache2/sites-enabled/*
希望有帮助,s1mmel