htaccess从一个链接重写到另一个链接同一目录

时间:2013-11-04 07:48:42

标签: .htaccess mod-rewrite

如何从此

重定向我的网站
http://www.mysite.org/forum/posts/129731/

http://www.mysite.org/forum/showthread.php?p=129731

http://www.mysite.org/forum/threads/hey-yall.12875

http://www.mysite.org/forum/showthread.php?t=12875

感谢

编辑:

http://pastebin.com/La5Vf5vH

添加htaccess请检查。我无法添加粘贴在pastebin中的代码

1 个答案:

答案 0 :(得分:0)

启用mod_rewrite.htaccesshttpd.conf(如果尚未启用),然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

RewriteEngine On

RewriteRule ^(forum)/posts/([0-9]+)/?$ /$1/showthread.php?p=$2 [L,QSA,NC]

RewriteRule ^(forum)/threads/(?:[^.]+\.)?([0-9]+)/?$ /$1/showthread.php?t=$2 [L,QSA,NC]