0

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&amp;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 ?

3
  • I don't know why you are making things complex, why don't you move WordPress installation to /WordPress/ instead of root folder. Jan 29 '19 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
    Jan 29 '19 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
    Jan 30 '19 at 5:58
0

The solution was :

  1. not use the index.php to include the folder /wordpress/
  2. not use wordpress/.htaccess
  3. 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.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>
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.