Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 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 Reply

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...