I want to serve a specific Wordpress page for multiple urls. Basically I want to point all the urls in a specific format to a known page:
/some-prefix-* => /target-page
And accessing /some-prefix-and-here-something
it should load /target-page
.
How to do this?
Note I do not want to redirect the user but to be able to serve an existing page to multiple urls.
The .htaccess
looks like this:
# 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
I thought by adding RewriteEngine On RewriteRule ^prefix-*$ some/path/to/directory-$1 [NC,L]
will serve /prefix-*
from some/path/to/directory-$1
. For example: when accessing example.com/prefix-foo
should be the same with example.com/some/path/to/directory-foo
(which resolves to example.com/some/path/to/directory-foo/index.html
).
Also, if there is already a Wordpress page with the name prefix-bar
, /prefix-bar
should not load example.com/some/path/to/directory-bar/index.html
.
RewriteRule prefix-(.*) target-page
?RewriteEngine On RewriteRule ^some-prefix-*$ http://example.com/target-page [R=301,L]