3

I have a qTranslate plugin that redirects all my pages with prefix /lt/. For example:

/page/ -> /lt/page/

I also have a custom PHP file that I want to reach in root folder /wp_import/check_mail.php

Now when I try to reach this file I get redirected to /lt/wp_import/check_mail.php

So I created a rule with:

add_rewrite_rule('/lt/wp_import/check_mail.php', '/wp_import/check_mail.php', 'top');

.htaccess generates this rule:

RewriteRule ^/lt/wp_import/check_mail.php //wp_import/check_mail.php [QSA,L]

However, I still get 404 wordpress page and I can't reach my custom PHP file.

NeuTronas
  • 263
  • 3
  • 11

1 Answers1

2

Apache ignores the leading slashes in the REQUEST_URI to match with your rules in .htaccess, thus rules starts with / and without RewriteBase will match nothing.

Try this:

RewriteRule ^lt/wp_import/check_mail.php wp_import/check_mail.php [QSA,L]
Haotian Liu
  • 886
  • 5
  • 19
  • I just removed slashes from add_rewrite_rule('lt/wp_import/check_mail.php', 'wp_import/check_mail.php', 'top'); and it worked. Thank you – NeuTronas Feb 20 '17 at 08:53