Php wordpress&x2B;nginx+;django:错误太多重定向
我刚刚将wordpress加入到一个项目中,以取代django作为网站的登录页。到目前为止,与服务器相关的一切都正常工作。我对修改nginx配置有点谨慎,因为我远不是该领域的专家 我曾尝试通过禁用我之前从django获得的内容来包含wordpress位置,这导致Php wordpress&x2B;nginx+;django:错误太多重定向,php,django,wordpress,nginx,Php,Django,Wordpress,Nginx,我刚刚将wordpress加入到一个项目中,以取代django作为网站的登录页。到目前为止,与服务器相关的一切都正常工作。我对修改nginx配置有点谨慎,因为我远不是该领域的专家 我曾尝试通过禁用我之前从django获得的内容来包含wordpress位置,这导致错误重定向过多 以下是我拥有的/nginx/sites enabled/conf.d的代码: server { server_name mysite.com www.mysite.com; root /var/www/h
错误重定向过多
以下是我拥有的/nginx/sites enabled/conf.d
的代码:
server {
server_name mysite.com www.mysite.com;
root /var/www/html;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location ^~ / {
alias /home/ubuntu/var/www/html/wordpress;
index index.php;
if (!-e $request_filename) { rewrite ^ /index.php last; }
location ~ /wp-content/uploads/ { expires 30d; }
location ~ \.php$ {
if (!-f $request_filename) { rewrite ^ /index.php last; }
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
if (!-f $request_filename) { rewrite ^ /index.php last; }
expires 30d;
}
}
}
server {
if ($host = www.mysite.com) {
return 301 https://$host$request_uri;
listen 80;
server_name mysite.com www.mysite.com;
return 404; # managed by Certbot
location ^~ / {
alias /home/ubuntu/var/www/html/wordpress;
index index.php;
if (!-e $request_filename) { rewrite ^ /index.php last; }
location ~ /wp-content/uploads/ { expires 30d; }
location ~ \.php$ {
if (!-f $request_filename) { rewrite ^ /index.php last; }
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
if (!-f $request_filename) { rewrite ^ /index.php last; }
expires 30d;
}
}
}
这是我的wp配置文件,除了db info之外,我没有添加任何内容:
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/support/article/editing-wp-config-php/
*
* @package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'dbsite1' );
/** MySQL database username */
define( 'DB_USER', 'root' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */
define( 'DB_HOST', 'host' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
在wordpress的wp\u config
表中检查url。不要使用alias
,而是尝试:root/home/ubuntu/var/www/html/wordpress
Charanjit,我一定是做错了什么,因为我没有在wp-config.php中配置任何URL。Richart,我试过使用root而不是alias,但仍然不起作用