自定义的.htaccess重写字preSS不执行规则 [英] Custom .htaccess rewrite rules in wordpress not executing
问题描述
问题:
我希望能够修改URL查询字符串参数以字为preSS的插件,并采取原始URL;
I'd like to be able to modify a url query string parameter for a plugin in wordpress, and take the original url;
的 /wp-admin/admin.php?page=es$p$psso_events 的
和能够通过对其进行访问;
and be able to access it via;
的 /wp-admin/admin.php?page=events 的
据我可以告诉我的.htaccess文件的一切是正确的,但由于某些原因,它仍然无法正常工作。然而,规则看起来很好,所以我不明白为什么字preSS抛出了我一个错误,当我尝试通过新的URL访问页面。
As far as I can tell everything in my .htaccess file is correct, but for some reason it still doesn't work. The rules however look fine, so I cannot understand why wordpress is throwing me an error when I try to access the page via the new url.
这是我的.htaccess文件;
This is my .htaccess file;
RewriteEngine On
RewriteBase /event_espresso/
RewriteRule ^index\.php$ - [L]
RewriteCond %{QUERY_STRING} ^(.*)events(.*)$
RewriteRule . wp-admin/admin.php?%1espresso_events%2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /event_espresso/index.php [L]
使用这的在线工具,它给了我正确的输出的URL,但是当我尝试直接输入网址在Word preSS,我只是每次都得到同样的错误;
Using this online tool, it gives me the correct output url, but when I try the input url directly in wordpress, I just get the same error each time;
您没有足够的权限来访问该页面。
You do not have sufficient permissions to access this page.
编辑:
这绝对是一个字preSS问题。当我手动更新我的.htaccess文件,一切工作正常,但是,使用 mod_rewrite_rules
过滤器时,文字preSS不会出现在写规则我.htaccess文件,或执行它们。我有我的.htaccess文件完全写入权限。
This is definitely a wordpress issue. When I manually update my .htaccess file, everything works correctly, however, when using the mod_rewrite_rules
filter, wordpress doesn't appear to be writing the rule to my .htaccess file, or executing them. I have full write permissions on my .htaccess file.
推荐答案
这个问题已经解决了,现在。我没有通过我的插件正确冲洗重写规则,所以我重写规则甚至没有被添加到.htaccess文件。
This issue has been resolved now. I wasn't flushing the rewrite rules properly via my plugin, so my rewrite rules weren't even being added to the .htaccess file.
function plugin_activate()
{
//make sure rewrite rules are flushed so the htaccess is written to
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
register_activation_hook(__FILE__, 'plugin_activate');
//actions..
这篇关于自定义的.htaccess重写字preSS不执行规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!