简体   繁体   中英

Wordpress htaccess rewriterule without changing URL

In WordPress I'm using the Events Manager plugin, which uses the /events/subpage path in the URL.

I need to tweak things slightly so that /courses/subpage rewrites to /events/subpage ie the content of /events/subpage is shown when going to /courses/subpage. The URL should stay as /courses.

I thought this rule would do it:

RewriteRule ^courses/?(.*)$ /events/$1 [L]

But the URL changes from /courses to /events so it looks like my rule isn't quite right.

EDIT Strangely I can put anything in place of /courses and it resolves to /events anyway. Confused!

Think I've cracked it.

I uninstalled the rewrite plugin and replaced it with Rewrite Rules Inspector. Then I added the following to functions.php add_rewrite_rule('^course/([^/]*)/?', 'index.php?event=$matches[1]', 'top'); // single event

In Rewrite Rules Inspector is said the rule was missing. I flushed the rules using the plugin and everything appears to be working now. It looks like the original rewrite plugin wasn't flushing the rules properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM