Wordpress RewriteRule for custom script

172 Views Asked by At

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.

1

There are 1 best solutions below

1
Haotian Liu On BEST ANSWER

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]