URL Rewriting in PHP using Wordpress

2019-09-07 13:34发布

I have to continue on a project that has been developed by someone else. It is a web portal developed using PHP and Wordpress. I am using the code uploaded on localhost. I had a fundamental question regarding URL rewriting in PHP. I have a link on the front page which says

a href="<?php bloginfo('url'); ?>/search?refer=registered&link=registered

But when I click on it, it gives a 404 error.

How do I set the URL mapping "search" -> "wp-content/themes/mytheme/page-search.php"?

[UPDATE: I found the solution myself. It had to be done through Wordpress by creating templates and setting the URL to point to the corresponding template file.]

标签: php wordpress
1条回答
Viruses.
2楼-- · 2019-09-07 14:13

wordpress build in url rewriting is in backend after you login /wp-admin/

go settings>permalinks where you can choose the re-write rules and click save button.

wordpress will then auto write a .htaccess file (this file is for url rewriting ) with the rules created in it.

if you find rewriting isn't working (eg, returns a 404 page) then u need to make sure your server has opened the url-rewrite mod for urlrewriting.

查看更多
登录 后发表回答