我有一个有几页的wordpress网站。
我想获得所有这些路径:
/events/first
/events/second/edit/
/events/whatever/foo/bar
已重定向至/show_event
,但是我想在浏览器中保留原始URL(/events/second/edit
),因为我在前端使用了react
脚本,需要对其进行读取。
这是我的htaccess文件:
RewriteEngine On
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteCond %{QUERY_STRING} !wc-api [NC]
RewriteCond %{HTTP_HOST} ^example$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
# RewriteRule ^(.*)$ https://example.com/$1 [R=301,L,NE]
# BEGIN iThemes Security
....
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
** MY CODE HERE **
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
这是我尝试过的:
RewriteRule ^events/.*$ https://example.com/show_event [NC,L]
RewriteRule ^events/.*$ ?pagename=show_event [NC,L]
这两个完成了重定向,但是URL中显示/show_event
,所以我不能使用它
RewriteRule ^events/.*$ show_event [NC,L]
RewriteRule ^events/.*$ /show_event [NC,L]
RewriteRule ^events/.*$ ^show_event [NC,L]
这三个规则都不起作用,我只是得到了一个wordpress页面,找不到错误页面
有什么想法吗?