Is this .htaccess section correct?

有些话、适合烂在心里 提交于 2019-12-14 03:13:19

问题


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:


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.



来源:https://stackoverflow.com/questions/19203009/is-this-htaccess-section-correct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!