Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

Trying move my Wordpress website hosted using Nginx and Bitnami to a different url path but the CSS and JS files become unavailable

So I tried changing the site-url and home in wp-config.php from

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');

to

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/blog');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/blog');

The website opens just fine, but the CSS and JS files are now getting picked up from

'wp.domain.com/blog/wp-content/....'

instead of

'wp.domain.com/wp-content/...'

and so the CSS and JS files are unavailable. I also tried doing the wp-options update but couldn't change anything.

Is there a solution or am I following the wrong process maybe?

Thanks!

question from:https://stackoverflow.com/questions/65641027/trying-move-my-wordpress-website-hosted-using-nginx-and-bitnami-to-a-different-u

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Bitnami Engineer here, please follow these steps to move the app to /blog

  • Log in to the server console using SSH.

  • Edit the /opt/bitnami/apps/wordpress/conf/nginx-prefix.conf file and update it to reflect the new path:

    location /blog {
      alias "/opt/bitnami/apps/wordpress/htdocs";
      include "/opt/bitnami/apps/wordpress/conf/nginx-app.conf"; 
    }
    
  • Look for the lines below in the file /opt/bitnami/apps/wordpress/htdocs/wp-config.php file:

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');
    
  • Modify them to reflect the new path, as below:

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
    
  • Restart NGINX:

    sudo /opt/bitnami/ctlscript.sh restart nginx
    

You can find more information in our documentation:

https://docs.bitnami.com/general/apps/wordpress-pro/administration/use-url-subpath/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...