我有一个BBPress论坛,它生成一个个人资料页面,如下所示:论坛/个人资料/用户名。
我想做的是使用.htaccess或重定向插件将此链接重定向到/ profile /USERNAME,并剪切掉配置文件部分。
做这件事最好的方法是什么?
干杯,
伊恩
发布于 2013-02-27 22:30:52
您可以在根目录下的.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被假定为动态,而forum和profile被假定为固定。
对于永久重定向,请用[R=301,L,NC]替换[L,NC]
发布于 2013-02-27 07:33:38
您可以在.htaccess文件中使用RedirectMatch (mod_alias的一部分)让服务器响应301:
//301 Redirect Entire Directory
RedirectMatch 301 ^/forum/profile/(.*) /profile/$1https://stackoverflow.com/questions/15101454
复制相似问题