dimanche 29 novembre 2015

wordpress rewrite rule added to custom plugin functions.php not work

Hello in my custom plugin i want to set custom rewrite rules. First i trying make this with one rule, so i create functions.php file in my plugin folder and i paste into this code:

    function xnineres_rewrite_rules() {
        add_rewrite_rule('^xnineres/([a-z]+)/?$','index.php?page_id=63&action=$matches[1]','top');
    }
    add_action('init', 'xnineres_rewrite_rules');

My custom plugin frontpage url was create thru wp-admin adding page and he look like this

http://ift.tt/1LHgZLw

When i go to rewrite target page via simple url http://ift.tt/1PlW0Wg WP automatically change url in browser address bar to http://ift.tt/1LHgZLz and loaded page is correct.

But why when i use in address bar url from rewrite_rule [http://ift.tt/1PlW0Wi] i got 404 page?

Also when i try do this thru .htaccess file (when rewrite is still enabled in WP), not everything is good. Using http://ift.tt/1PlW0Wi url WP automatically redirect to http://ift.tt/1LHgZLw so he completly skips the variables of url query. This also it happens when i change in my .htaccess file rule from ^xnineres/([a-z]+)/$ to ^([a-z]+)/$. Now when i use http://ift.tt/1LHh1TK WP automatically redirect to page http://ift.tt/1LHgZLw

I really don't understand why this it happen. Can sombody help do this correctly?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire