• 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 as siteurl and home.

    Problem seems to be add_rewrite_rule() second parameter $query which is provided as full URL instead of relative path to siteurl 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() and plugins_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)
  • Plugin Author enzomangiante

    (@enzomangiante)

    Hey, thanks for all your feedbacks, solution will be available in our new release tomorrow.

    Thread Starter Ov3rfly

    (@ov3rfly)

    Installed 5.8.4 update, observed these things:

    Have to use WordPress > Settings > Permalinks > Update (without changes) to get the .htaccess entries rewritten.

    Getting two slashes in paths because site_url() which you use to cut the domain part returns path without trailing slash.

    RewriteBase /blog/
    RewriteRule ^index\.php$ - [L]
    RewriteRule ^event-feed/? /blog//wp-admin/admin-ajax.php?action=EventPostFeed [QSA,L]
    RewriteRule ^eventpost/([0-9]*)\.(ics|vcs)? /blog//wp-content/plugins/event-post/export/ics.php [QSA,L]

    Maybe siteurl( '/' ) would be a solution here – untested.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wrong use of add_rewrite_rule() for .htaccess’ is closed to new replies.