我想重新访问我的整个wordpress,除了主页和另一个页面。我发现的问题是,可以访问另一个页面,但不能访问主页。
我的wordpress安装在nginx反向代理之后
location /wordpress/ {
proxy_pass http://192.168.1.12/;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
在另一台nginx服务器上
server {
listen 80 default_server;
server_name 192.168.1.12;
root /var/www/html/wordpress;
index index.php index.html index.htm;
access_log /var/log/nginx/default.access.log;
error_log /var/log/nginx/default.error.log;
## WordPress Perm links config ##
location / {
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \\.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\\.ht {
deny all;
}
}
wordpress wp配置。为ssl修改了php
if ( (!empty( $_SERVER[\'HTTP_X_FORWARDED_HOST\'])) ||
(!empty( $_SERVER[\'HTTP_X_FORWARDED_FOR\'])) ) {
$_SERVER[\'HTTPS\'] = \'on\';
}
主题的功能。修改php以限制访问
function restrict_access_if_logged_out(){
global $wp;
if (!is_user_logged_in() && !is_home() && ($wp->query_vars[\'pagename\'] != \'portail-identification\') && ($wp->query_vars[\'pagename\'] != \'portail-stagiaire\') ){
wp_safe_redirect(wp_login_url(get_permalink()));
exit;
}
}
add_action( \'wp\', \'restrict_access_if_logged_out\', 3 );
也在上创建了相同的问题
https://stackoverflow.com/questions/53157349/restrict-access-if-logged-out-except-for-wordpress-homepage