I installed my plugin for one of my clients but I got a bug.
In my plugin settings page using the wordpress settings system, when I click on the submit button to activate a license key, the reditection is https://my-site/wp-admin/options-general.php?page=settings-my-plugin&tab=premium&action=activate
instead of https://my-site/wordpress/wp-admin/options-general.php?page=settings-my-plugin&tab=premium&action=activate
I searched the problem and this is the result :
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"); ?>
So, how can I resolved this problem to match with any admin url ?
I installed my plugin for one of my clients but I got a bug.
In my plugin settings page using the wordpress settings system, when I click on the submit button to activate a license key, the reditection is https://my-site/wp-admin/options-general.php?page=settings-my-plugin&tab=premium&action=activate
instead of https://my-site/wordpress/wp-admin/options-general.php?page=settings-my-plugin&tab=premium&action=activate
I searched the problem and this is the result :
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"); ?>
So, how can I resolved this problem to match with any admin url ?
Share Improve this question edited Jan 28, 2019 at 13:34 J.BizMai asked Jan 28, 2019 at 12:53 J.BizMaiJ.BizMai 9302 gold badges10 silver badges30 bronze badges 3- I don't know why you are making things complex, why don't you move WordPress installation to /WordPress/ instead of root folder. – Arvind Singh Commented Jan 29, 2019 at 9:10
- @ArvindSingh, It´s my client´s project. The ex-developer do this because he kept an old version in a folder on the root as well. But I already resolved it. You can see the solution here. – J.BizMai Commented Jan 29, 2019 at 12:21
- @J.BizMai, could you add the solution as answer here and mark it as solved. So ppl don't need to follow links to other forum(s) and see the question has an answer. – Charles Commented Jan 30, 2019 at 5:58
1 Answer
Reset to default 0The solution was :
- not use the index.php to include the folder /wordpress/
- not use wordpress/.htaccess
use only .htaccess to point to subfolder
<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$ #point to subfolder RewriteCond %{REQUEST_URI} !^/wordpress/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /wordpress/$1 RewriteCond %{HTTP_HOST} ^(www.)?my-site$ RewriteRule ^(/)?$ wordpress/index.php [L] </IfModule>