Installed WP in a subdir, can access wp-admin, but URLs are getting re-written without the subdir PATH. Where do I set this?

Ph. Gras ph.gras at worldonline.fr
Mon Apr 30 21:38:48 UTC 2018


Hello there!


> I've installed WP in a site subdir.
> 
> I can now access wp-admin pages at the expected URL.
> 
> Sort of.  I can get there manually, but my site config keeps redirecting, stripping URLs of the subdir path to WordPress.
> 
> My config now has
> 
> 	wp-config.php
> 		<?php
> 			define('WP_HOME',   'https://test.example.com/blog');
> 			define('WP_SITEURL','https://test.example.com/blog');

According to the documentation:
https://codex.wordpress.org/Editing_wp-config.php#WP_SITEURL

you should define the Home and Website URL so :
define( 'WP_SITEURL', 'http://test.example.com/srv/www/test/wp/public' );
define( 'WP_HOME', 'http://test.example.com/blog' );

> 
> 
> and for Nginx

	server {

	blah-blah;
	root /srv/www/test/wp/public;
	index index.php; 
> 

	??????????? =>
> 	location ^~ /blog {
> 		root /srv/www/test/wp/public;
> 
> 		index index.php;
		# Not necessary, but don't forget index in the SERVER BLOCK


> 		}
> 	}
> 
	?????????
> 	location / {
> 		root /srv/www/test/public;
> 
> 		index index.php;
> 		try_files $uri $uri/ /index.php?$args;
> 
> 		location ~ \.php {
> 			try_files $uri =404;
> 			include fastcgi_params;
> 			fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
> 			fastcgi_pass phpfpm;
> 			fastcgi_index index.php;
> 		}
> 	}
> 
	location ~ \.php$ {
		include /etc/nginx/snippets/fastcgi-php.conf;
		fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
		}


You can visit this page too:
https://codex.wordpress.org/Nginx

Regards,

Ph. Gras


More information about the nginx mailing list