如何在根目录设置 WordPress 但仍使用 /用户名 URL?
我正在建立一个使用 WordPress 作为主要 CMS 的网站。会有很多静态页面和博客。网址将是:
除了默认的博客 URL 之外,我还想提供用户名 URL,例如:
注意:这些用户名与 WordPress 博客用户名无关。它们将来自另一个数据库。
我正在考虑设置 WordPress 404.php 处理程序以将 /whatever
视为用户名,因为 WordPress 不会处理它们(这意味着它们'可能是用户名)。如果查询字符串是 /whatever/something/else
,我将显示常规 404 消息,因为这可能不是用户名请求。
这是解决这个问题的好方法吗?或者我应该修改 .htaccess
以将 WordPress 放弃的内容路由到独立的 /user.php?username=whatever
?还有其他方法可以完成此任务吗?
I'm setting up a website using WordPress as the main CMS. There will be lots of static pages and a blog. URLs will be:
In addition to the default blog URLs, I also want to provide username URLS such as:
Note: These usernames have nothing to do with the WordPress blog usernames. They will be from another database.
I'm thinking of setting up the WordPress 404.php handler to consider /whatever
as usernames, because WordPress will not have handled them (which means they're probably usernames). In case the query string is /whatever/something/else
, I'll display a regular 404 message, because that probably wasn't a username request.
Is this a good, acceptable way to work this out or should I be modifying the .htaccess
to route stuff given up by WordPress into an independent /user.php?username=whatever
? Is there any other way to get this done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 http://www.example.com/users/whatever 作为 URL 怎么样?用户页面? /users/ 将为您提供一个唯一的 URL,用于识别用户页面。
然后可以根据您的示例将此 URL 格式重定向到 /user.php?username=whatever 。
What about using http://www.example.com/users/whatever as the URL for the user pages? The /users/ will give you a unique URL by which to identify the user pages.
This URL format could then be redirected to /user.php?username=whatever as per your example.