Using a RewriteRule to display a WordPress page
-
Hi,
Let’s say my blog is foo.com and I have WordPress installed in foo.com/wp. I’d like to be able to go to https://foo.com/x/ and have it show me https://foo.com/wp/index.php?p=296 while keeping “https://foo.com/x/” in the location bar. To do this, I created a .htaccess file in the root directory for foo.com containing this:
RewriteEngine on RewriteRule ^/?x/?$ /wp/index.php?p=296
When I go to foo.com/x/, I get WordPress’s “Not Found” page. However, if I change my .htaccess to this:
RewriteEngine on RewriteRule ^/?x/?$ /wp/index.php?p=296 [R]
then everything works great. The page I want displays, but since Apache sent out a redirect, the URL in the location bar has changed as well. Is there any way I can make this RewriteRule do what I want? Thanks!
- The topic ‘Using a RewriteRule to display a WordPress page’ is closed to new replies.