如何重定向博客文章网址?

时间:2016-01-16 16:12:52

标签: .htaccess mod-rewrite url-rewriting symphony-cms

我正在尝试使用.htaccess文件重定向一堆旧的博客文章网址:

RedirectMatch ^/index\.php/global/article/(.*)$ http://www.mywebsite.com/blog/article/$1

然而,这确实不起作用,因为我的CMS似乎对index.php位感到困惑,并不断向所有网址添加?symphony-page=

可能这部分负责:

### FRONTEND REWRITE - Will ignore files and folders
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}    [L]

有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

试试这个:

#-- Input URL >>  http://www.mywebsite.com/index.php/global/article/abc


### FRONTEND REWRITE - Will ignore files and folders
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING}

RewriteCond %{REQUEST_URI} ^/index\.php/global/article/(.*)$
RewriteRule ^.*$ blog/article/%1  [R=301, L]


#--Output URL >>  http://www.mywebsite.com/blog/article/abc

我已使用此htaccess.madewithlove对上述内容进行了测试,看起来效果会很好,希望它也能为您效果

截图:

enter image description here

答案 1 :(得分:1)

请尝试以下方法(包括解释说明):

RewriteEngine On

# First, redirect the old URIs to the new ones via a 301 redirect.
# This will allow the CMS to take over using the rules that follow.
RewriteRule ^index.php/global/article/(.+)$ /blog/article/$1 [L,R=301]

# Frontend Rewrites - for the CMS
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*\/?)$ index.php?symphony-page=$1&%{QUERY_STRING} [L]
相关问题