2014-12-02 101 views
-2

我想重定向以下301將showthread.php?t = 1&page = 2重定向到threads/1/page-2?

http://www.example.com/showthread.php?t=1&page=2http://www.example.com/threads/1/page-2

http://www.example.com/showthread.php?t=1http://www.example.com/threads/1

我想 「301重定向」 它不是 「重寫」,即我想要的 「http://www.example.com/showthread.php?t=1&page=2」鏈接到301重定向到文件夾結構。

請指教?

+0

那你試試,你在哪裏卡住? – Novocaine 2014-12-02 11:12:54

回答

0

您可以使用:

RewriteEngine on 
RewriteBase/

# external redirect from actual URL to pretty one 
RewriteCond %{THE_REQUEST} \s/+showthread\.php\?t=(\d+)&page=(\d+) [NC] 
RewriteRule^/threads/%1/page-%2? [R=301,L,NE] 
RewriteCond %{THE_REQUEST} \s/+showthread\.php\?t=(\d+) [NC] 
RewriteRule^/threads/%1? [R=301,L,NE] 

# not for file or directory 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

# internal forward from pretty URL to actual one 
RewriteRule ^threads/(\d+)/page-(\d+)/?$ /showthread.php?t=$1&page=$2 [L,NC] 
RewriteRule ^threads/(\d+)/?$ /showthread.php?t=$1 [L,NC]