简体   繁体   中英

URL Rewriting in PHP using Wordpress

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.]

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM