我为我的一个客户安装了插件,但我遇到了一个bug。
在使用wordpress设置系统的插件设置页面中,当我单击提交按钮激活许可证密钥时,重新检测是https://my-site/wp-admin/options-general.php?page=settings-my-plugin&tab=premium&action=activate
而不是https://my-site/wordpress/wp-admin/options-general.php?page=settings-my-plugin&tab=premium&action=activate
我搜索了问题,结果如下:
echo \'<form method="post" action="options.php">\'; //initial code - wrong redirection
<input type="hidden" name="_wp_http_referer" value="/wordpress/wp-admin/options-general.php?page=settings-my-plugin&tab=premium">//seems to be correct
admin_url(); //write https://my-site/wordpress/wp-admin/
printf( \'<form method="post" action="%soptions.php">\', admin_url() ); //same redirection error
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
wordpress/.htaccess
# BEGIN s2Member GZIP exclusions
<IfModule rewrite_module>
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{QUERY_STRING} (^|\\?|&)s2member_file_download\\=.+ [OR]
RewriteCond %{QUERY_STRING} (^|\\?|&)no-gzip\\=1
RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions
# BEGIN WordPress
# END WordPress
[root]index.php
<?php //include_once("wordpress/index.php"); ?>
那么,如何解决此问题以匹配任何管理员url?
最合适的回答,由SO网友:J.BizMai 整理而成
解决方案是:
不要使用索引。php要包含文件夹/wordpress/,请不要使用wordpress/。htaccess仅限使用。htaccess指向子文件夹
<IfModule mod_rewrite.c>
RewriteEngine On
#https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} ^(www.)?my-site.com$
#point to subfolder
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1
RewriteCond %{HTTP_HOST} ^(www.)?my-site.com$
RewriteRule ^(/)?$ wordpress/index.php [L]
</IfModule>