我想为多个URL提供一个特定的Wordpress页面。基本上,我希望以特定格式将所有URL指向已知页面:
/some-prefix-* => /target-page
和访问/some-prefix-and-here-something
它应该加载/target-page
.如何做到这一点?
注意:我不想重定向用户,但希望能够将现有页面服务于多个URL。
这个.htaccess
如下所示:
# BEGIN s2Member GZIP exclusions
RewriteEngine On RewriteRule ^prefix-*$ some/path/to/directory-$1 [NC,L]
<IfModule rewrite_module>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|\\?|&)s2member_file_download\\=.+ [OR]
RewriteCond %{QUERY_STRING} (^|\\?|&)no-gzip\\=1
RewriteRule .* - [E=no-gzip:1]
</IfModule>
# END s2Member GZIP exclusions
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
DirectoryIndex index.php index.html
我想通过添加RewriteEngine On RewriteRule ^prefix-*$ some/path/to/directory-$1 [NC,L]
将提供/prefix-*
从…起some/path/to/directory-$1
. 例如:访问时example.com/prefix-foo
应与相同example.com/some/path/to/directory-foo
(决定example.com/some/path/to/directory-foo/index.html
).此外,如果已经有一个名为的Wordpress页面prefix-bar
, /prefix-bar
不应加载example.com/some/path/to/directory-bar/index.html
.