1

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

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

然而,这并没有真正起作用,因为我的 CMS 似乎被这index.php点弄糊涂了,并不断添加?symphony-page=到所有 URL。

可能是这部分负责:

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

有人可以帮忙吗?

4

2 回答 2

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测试了上面的内容,它似乎可以正常工作,希望它也对你有用

截屏:

在此处输入图像描述

于 2016-01-16T16:47:18.503 回答
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]
于 2016-01-17T06:07:18.727 回答