我有一个不寻常的设置,我有一个angularJS应用程序运行在http://example.com
,它通过位于http://api.example.com
的wordpress api提取数据。WordPress的NGINX重定向到一个新的领域除了
http://api.example.com
需要有/wp-login
,/wp-admin
,/wp-content
,和/wp-includes
网址,就好像它仍然是一个普通的WordPress网站的工作。
但是所有其他的URL像http://api.example.com/category/excategory
或http://api.example.com/this-is-a-post-title
需要301重定向到http://example.com domain.
例如:
http://api.example.com/category/excategory
重定向到
http://example.com/category/excategory
但
http://api.example.com/wp-admin (and anything after it)
没有。
我尝试了各种疯狂的东西,但我的位置块似乎要么冲突,要么我得到奇怪的网址,无处可去。
这里的失败尝试:
location ~ /wp-(?:admin|login|includes|content) {
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location/{
return 301 $scheme//example.com$request_uri
}
尝试更新您的永久链接结构。看看你的.htaccess文件是否可写。 –
考虑到这是一个NGINX设置,.htaccess会是一个合适的解决方案吗? –
嗯,.htaccess不是一个合适的解决方案。尝试将永久链接结构设置为默认,并且看到您可以访问网页。 –