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 ?
The solution was :
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>