0

I've recently migrated a forum from vBulletin to SMF and I'm having trouble creating a RewriteCond/RewriteRule that converts the URL http://www.fjcc.com.au/showthread.php?t=3133&page=2 to the URL http://fjcc.com.au/forum_fjcc/index.php?topic=3133.0.

The .htaccess file in the root directory looks like this:

RewriteEngine On

# SMF Rewrite rules for vBulletin links after vBSEO removed
RewriteCond %{QUERY_STRING} ^t=([0-9]+)&page=[0-9]+/?$
RewriteRule ^showthread.php$ /forum_fjcc/index.php?topic=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^t=([0-9]+).*&p=([0-9]+)/?$
RewriteRule ^showthread.php$ /forum_fjcc/index.php?topic=%1.msg%2#msg%2 [L,R=301]
RewriteCond %{QUERY_STRING} ^t=([0-9]+)/?$
RewriteRule ^showthread.php$ /forum_fjcc/index.php?topic=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^f=([0-9]+)&page=[0-9]+/?$
RewriteRule ^forumdisplay.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^f=([0-9]+)/?$
RewriteRule ^forumdisplay.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^do=newthread.f=([0-9]+)/?$
RewriteRule ^newthread.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^r=author/([0-9]+)-.*/?$

# SMF Rewrites for cms directory
RewriteRule ^cms/list.php$ /forum_fjcc/index.php?action=profile;u=%1 [L,R=301]
RewriteCond %{QUERY_STRING} ^t=([0-9]+)&page=[0-9]+/?$

# SMF Rewrites for forum directory
RewriteCond %{QUERY_STRING} ^t=([0-9]+)&page=[0-9]+/?$
RewriteRule ^forum/showthread.php$ /forum_fjcc/index.php?topic=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^t=([0-9]+).*&p=([0-9]+)/?$
RewriteRule ^forum/showthread.php$ /forum_fjcc/index.php?topic=%1.msg%2#msg%2 [L,R=301]
RewriteCond %{QUERY_STRING} ^t=([0-9]+)/?$
RewriteRule ^forum/showthread.php$ /forum_fjcc/index.php?topic=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^f=([0-9]+)&page=[0-9]+/?$
RewriteRule ^forum/forumdisplay.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^f=([0-9]+)/?$
RewriteRule ^forum/forumdisplay.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]
RewriteCond %{QUERY_STRING} ^do=newthread.f=([0-9]+)/?$
RewriteRule ^forum/newthread.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]

# SMF Rewrite rules for vBulletin links before vBSEO removed
RewriteRule ^f[\d]+/.+-([\d]+).*/index([\d]+).html/?$ /forum_fjcc/index.php?topic=$1.0 [L,R=301]
RewriteRule ^f([\d]+)/index([\d]+).html/?$ /forum_fjcc/index.php?board=$1.0 [L,R=301]
RewriteRule ^f[\d]+/.+-([\d]+)-post([\d]+)/?$ /forum_fjcc/index.php?topic=$1.msg$2#msg$2 [L,R=301]
RewriteRule ^f[\d]+/.+-([\d]+).*/?$ /forum_fjcc/index.php?topic=$1.0 [L,R=301]
RewriteRule ^f([\d]+)/?$ /forum_fjcc/index.php?board=$1.0 [L,R=301]
RewriteRule ^archive/index.php/t-([\d]+).*html/?$ /forum_fjcc/archive2.php?topic=$1.0 [L,R=301]
RewriteRule ^archive/index.php/f-([\d]+).*html/?$ /forum_fjcc/archive2.php?board=$1.0 [L,R=301]
RewriteRule ^archive/index.php/?$ /forum_fjcc/archive2.php [L,R=301]
RewriteRule ^members/([\d]+).html/?$ /forum_fjcc/index.php?action=profile;u=$1 [L,R=301]

Redirect 301 /index.php /forum_fjcc/
Redirect 301 /forum/showthread.php /forum_fjcc/index.php
Redirect 301 /showthread.php /forum_fjcc/index.php
Redirect 301 /blog/entry.php /forum_fjcc/index.php
Redirect 301 /entry.php /forum_fjcc/index.php
Redirect 301 /blog/blog.php /forum_fjcc/index.php
Redirect 301 /blog.php /forum_fjcc/index.php
Redirect 301 /cms/content.php /forum_fjcc/index.php
Redirect 301 /forum/ /forum_fjcc/index.php

According to the MWL htaccess Tester the rules should return the URL I listed above but that isn't happening - I'm getting /forum_fjcc/index.php?t=3133&page=2 (prefixed by the website URL) instead.

I've been working on this issue for more than a week and I've tried every RewriteCond/RewriteRule combination I've found without any success - hoping someone can point me in the right direction.

4

1 回答 1

0

我终于为自己解决了这个问题(并在此过程中成功合并了一些 RewriteCond/RewriteRule 集)

问题是“重定向 301 /showthread.php /forum_fjcc/index.php”语句(虽然我不明白为什么,因为重写 URL 的语句出现在文件的前面并且有标志 [L,R=301]在最后)。

我的工作 .htacecss 文件现在看起来像这样:

# SMF rewrites for vBulletin after vBSEO removed (including forum directory)

RewriteCond %{QUERY_STRING} ^t=([0-9]+)&page=[0-9]+&p=([0-9]+)#[0-9]+(.*)?/?$ [OR]
RewriteCond %{QUERY_STRING} ^t=([0-9]+)&page=[0-9]+&p=([0-9]+)(.*)?/?$
RewriteRule ^(forum)?/?showthread.php$ /forum_fjcc/index.php?topic=%1.msg%2#msg%2 [L,R=301]

RewriteCond %{QUERY_STRING} ^t=([0-9]+)&page=[0-9]+(.*)?/?$ [OR]
RewriteCond %{QUERY_STRING} ^t=([0-9]+)(.*)?/?$
RewriteRule ^(forum)?/?showthread.php$ /forum_fjcc/index.php?topic=%1.0 [L,R=301]

RewriteCond %{QUERY_STRING} ^f=([0-9]+)&page=[0-9]+(.*)?/?$ [OR]
RewriteCond %{QUERY_STRING} ^f=([0-9]+)(.*)?/?$
RewriteRule ^(forum)?/?forumdisplay.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]

RewriteCond %{QUERY_STRING} ^do=newthread.f=([0-9]+)(.*)?/?$
RewriteRule ^(forum)?/?newthread.php$ /forum_fjcc/index.php?board=%1.0 [L,R=301]

# SMF rewrites for vBulletin before vBSEO removed
RewriteRule ^f[\d]+/.+-([\d]+).*/index([\d]+).html/?$ /forum_fjcc/index.php?topic=$1.0? [L,R=301]
RewriteRule ^f([\d]+)/index([\d]+).html/?$ /forum_fjcc/index.php?board=$1.0? [L,R=301]
RewriteRule ^f[\d]+/.+-([\d]+)-post([\d]+)/?$ /forum_fjcc/index.php?topic=$1.msg$2#msg$2? [L,R=301]
RewriteRule ^f[\d]+/.+-([\d]+).*/?$ /forum_fjcc/index.php?topic=$1.0? [L,R=301]
RewriteRule ^f([\d]+)/?$ /forum_fjcc/index.php?board=$1.0? [L,R=301]
RewriteRule ^archive/index.php/t-([\d]+).*html/?$ /forum_fjcc/archive2.php?topic=$1.0? [L,R=301]
RewriteRule ^archive/index.php/f-([\d]+).*html/?$ /forum_fjcc/archive2.php?board=$1.0? [L,R=301]
RewriteRule ^archive/index.php/?$ /forum_fjcc/archive2.php? [L,R=301]
RewriteRule ^members/([\d]+).html/?$ /forum_fjcc/index.php?action=profile;u=$1? [L,R=301]

# SMF rewrite for cms author
RewriteCond %{QUERY_STRING} ^r=author/([0-9]+)-.*/?$
RewriteRule ^cms/list.php$ /forum_fjcc/index.php?action=profile;u=%1? [L,R=301]

# SMF rewrite for calendar
RewriteRule ^calendar\.php /forum_fjcc/index.php?action=calendar? [L,R=301]

# Other rewrites
Rewrite ^blog\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^index\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^entry\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^showthread\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^blog/blog\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^blog/entry\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^cms/content\.php /forum_fjcc/index.php? [L,R=301]
Rewrite ^forum/ /forum_fjcc/index.php? [L,R=301]
于 2017-06-29T07:21:45.937 回答