Wrong use of add_rewrite_rule() for .htaccess
-
While debugging a client website with Event Post 5.8.3 and WordPress 6.1.1, we found strange invalid entries in two
RewriteRule
lines added by the plugin in.htaccess
WordPress block:# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase /blog/ RewriteRule ^index\.php$ - [L] RewriteRule ^event-feed/? /blog/https://www.example.com/blog/wp-admin/admin-ajax.php?action=EventPostFeed [QSA,L] RewriteRule ^eventpost/([0-9]*)\.(ics|vcs)? /blog/https://www.example.com/blog/wp-content/plugins/event-post/export/ics.php [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> # END WordPress
Website uses
https://www.example.com/blog
assiteurl
andhome
.Problem seems to be
add_rewrite_rule()
second parameter$query
which is provided as full URL instead of relative path tositeurl
and causes invalid/blog/https://www.example.com/blog/wp-...
entries.public function init(){ add_rewrite_rule('event-feed/?', admin_url('admin-ajax.php?action=EventPostFeed'), 'top'); add_rewrite_rule('eventpost/([0-9]*)\.(ics|vcs)?', plugins_url('export/ics.php', __FILE__), 'top'); }
Use of
admin_url()
andplugins_url()
here is wrong.Fixing this might also require adjustments here, but we did not test further.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Wrong use of add_rewrite_rule() for .htaccess’ is closed to new replies.