Is this .htaccess section correct?

2019-09-19 19:07发布

I have created a .htaccess file in the base of my wordpress installation on dreamhost, but it doesn't seem to be working yet. Want to direct any requests to page_id of 7 to the page id of 43.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule http://www.myapp.com/?page_id=7 /?page_id=43 [NC,L]
</IfModule>

Actually do I need to do anything to trigger apache to pick this up too, other than just saving the file? Any way to look for log file entries to help pin point the issue?

1条回答
不美不萌又怎样
2楼-- · 2019-09-19 19:30

Try the following:

RewriteEngine On
RewriteCond %{QUERY_STRING} page_id=7
RewriteRule ^(.*)$ /?page_id=43 [NC,L]

With this ruleset you can also be a lot more specific by e.g. providing an optional pretty URL that pointed to the same page, etc.

查看更多
登录 后发表回答