【问题标题】:Redirecting WordPress profile page重定向 WordPress 个人资料页面
【发布时间】:2013-02-27 22:30:52
【问题描述】:

我有一个 BBPress 论坛,它会生成这样的个人资料页面:forum/profile/USERNAME。

我想要做的是使用 .htaccess 或重定向插件将此链接重定向到 /profile/USERNAME 并删除配置文件部分。

最好的方法是什么?

干杯,

伊恩

【问题讨论】:

  • and cut out the profile part... 文件夹/profile 来自forum/profile/USERNAME?请解释一下。
  • 我希望它从 sitename.com/forum/profile/username/ 重定向到 sitename.com/profile/username/

标签: regex wordpress .htaccess


【解决方案1】:

你可以在根目录下的 .htaccess 文件中试试这个:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forum/profile/([^/]+)/?  /profile/$1  [L,NC]

静默地图

http://sitename.com/forum/profile/username/

http://sitename.com/profile/username/

字符串username 假定为动态,而forumprofile 假定为固定。

对于永久重定向,将[L,NC] 替换为[R=301,L,NC]

【讨论】:

    【解决方案2】:

    您可以使用 .htaccess 文件中的 RedirectMatch(mod_alias 的一部分)让服务器以 301 响应:

    //301 Redirect Entire Directory
    RedirectMatch 301 ^/forum/profile/(.*) /profile/$1
    

    【讨论】:

    • 这就是我尝试这样做的方式,但它不起作用。我想知道 BBPress 是否有自己的覆盖 301 的 htaccess?
    猜你喜欢
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    • 2012-01-24
    • 1970-01-01
    • 2015-02-28
    相关资源
    最近更新 更多