使用 Wordpress 在 PHP 中重写 URL [英] URL Rewriting in PHP using Wordpress
问题描述
我必须继续一个别人开发的项目.它是一个使用 PHP 和 Wordpress 开发的 Web 门户.我正在使用在本地主机上上传的代码.我有一个关于 PHP 中 URL 重写的基本问题.我在首页有一个链接,上面写着
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
但是当我点击它时,它给出了 404 错误.
But when I click on it, it gives a 404 error.
如何设置 URL 映射搜索"->wp-content/themes/mytheme/page-search.php"?
How do I set the URL mapping "search" -> "wp-content/themes/mytheme/page-search.php"?
[更新:我自己找到了解决方案.它必须通过 Wordpress 创建模板并将 URL 设置为指向相应的模板文件来完成.]
[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/
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 将自动写入一个 .htaccess 文件(该文件用于 url 重写)使用其中创建的规则.
wordpress will then auto write a .htaccess file (this file is for url rewriting ) with the rules created in it.
如果您发现重写不起作用(例如,返回 404 页面),那么您需要确保您的服务器已打开用于 urlrewriting 的 url-rewrite mod.
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.
这篇关于使用 Wordpress 在 PHP 中重写 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!