WordPress .htaccess 行为怪异
Wordpress .htaccess acting weird
我在 WP Local 中创建了一个 WP 站点,并且只是在测试部署过程。我使用 WP Local 本身导出它并上传了 app/public 文件夹,其中包含 wp-admin、wp-content、wp-includes 及其所有文件。
为数据库连接配置 wp-config,手动设置我的 siteurl 和 home 以匹配域(atm,它是一个子域,所以我使用这个)。它也是通过 cloudflare 的 SSL,所以我使用 https:// 作为前缀。
我进入管理面板,设置 - 常规并检查 URL 主页和站点,然后单击保存以确保缓存。然后我进入设置 - 永久链接并将所有内容保存在那里。
结果 -> 主页有效,其他主页无效(wp-admin 有效)所以我认为我的 mod 重写无效。
Mod 重写 module 已激活,这些是我的 apache conf:
<VirtualHost *:80>
ServerAdmin myemail@test.be
ServerName subdomain.domain.be
DocumentRoot /var/www/wp-root-path
<Directory /var/www/wp-root-path>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/subdomain.domain.be.error.log
CustomLog ${APACHE_LOG_DIR}/subdomain.domain.be.access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin myemail@test.be
ServerName subdomain.domain.be
DocumentRoot /var/www/subdomain.domain.be
ErrorLog ${APACHE_LOG_DIR}/subdomain.domain.be.error.log
CustomLog ${APACHE_LOG_DIR}/subdomain.domain.be.access.log combined
SSLEngine on
SSLCertificateFile /etc/cloudflare/path-to-cloudflare.pem
SSLCertificateKeyFile /etc/cloudflare/path-to-cloudflare.key
</VirtualHost>
我尝试更改永久链接设置,删除 .htaccess 文件(保存后重新生成),.htaccess 的权限为 644..
我觉得一切都很好,但事实并非如此?有小费吗?提前致谢!
DocumentRoot /var/www/wp-root-path
<Directory /var/www/wp-root-path>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
您的 <VirtualHost *:443>
容器似乎缺少一半必要的配置指令?
您的 vHost:443 容器设置不同 DocumentRoot
?您也未能在 vHost:443 容器中允许 .htaccess
覆盖,因此任何“漂亮”的永久链接都将失败 (404)。而且您也不允许访问。
我假设您使用的是 Apache 2.4(而不是 Apache 2.2),因此您应该使用 Require all granted
,而不是已弃用的 Order
和 Allow
指令。
您还缺少 vHost:443 容器中的 SetHandler
指令吗?
我在 WP Local 中创建了一个 WP 站点,并且只是在测试部署过程。我使用 WP Local 本身导出它并上传了 app/public 文件夹,其中包含 wp-admin、wp-content、wp-includes 及其所有文件。
为数据库连接配置 wp-config,手动设置我的 siteurl 和 home 以匹配域(atm,它是一个子域,所以我使用这个)。它也是通过 cloudflare 的 SSL,所以我使用 https:// 作为前缀。
我进入管理面板,设置 - 常规并检查 URL 主页和站点,然后单击保存以确保缓存。然后我进入设置 - 永久链接并将所有内容保存在那里。
结果 -> 主页有效,其他主页无效(wp-admin 有效)所以我认为我的 mod 重写无效。
Mod 重写 module 已激活,这些是我的 apache conf:
<VirtualHost *:80>
ServerAdmin myemail@test.be
ServerName subdomain.domain.be
DocumentRoot /var/www/wp-root-path
<Directory /var/www/wp-root-path>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/subdomain.domain.be.error.log
CustomLog ${APACHE_LOG_DIR}/subdomain.domain.be.access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin myemail@test.be
ServerName subdomain.domain.be
DocumentRoot /var/www/subdomain.domain.be
ErrorLog ${APACHE_LOG_DIR}/subdomain.domain.be.error.log
CustomLog ${APACHE_LOG_DIR}/subdomain.domain.be.access.log combined
SSLEngine on
SSLCertificateFile /etc/cloudflare/path-to-cloudflare.pem
SSLCertificateKeyFile /etc/cloudflare/path-to-cloudflare.key
</VirtualHost>
我尝试更改永久链接设置,删除 .htaccess 文件(保存后重新生成),.htaccess 的权限为 644..
我觉得一切都很好,但事实并非如此?有小费吗?提前致谢!
DocumentRoot /var/www/wp-root-path <Directory /var/www/wp-root-path> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> <FilesMatch \.php$> SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost" </FilesMatch>
您的 <VirtualHost *:443>
容器似乎缺少一半必要的配置指令?
您的 vHost:443 容器设置不同 DocumentRoot
?您也未能在 vHost:443 容器中允许 .htaccess
覆盖,因此任何“漂亮”的永久链接都将失败 (404)。而且您也不允许访问。
我假设您使用的是 Apache 2.4(而不是 Apache 2.2),因此您应该使用 Require all granted
,而不是已弃用的 Order
和 Allow
指令。
您还缺少 vHost:443 容器中的 SetHandler
指令吗?