2012-05-06 76 views
0

我安装了SocialEngine以替换旧的CMS。问题在于搜索引擎中存在很多旧的URL。我想将它们重定向到当前网站上的相应网址(因为目前它们只能重定向到首页)。SocialEngine - 301重定向旧网站页面.htaccess

我的旧CMS的所有内容都被导入到SE中,因此每个旧页面现在都有相同的内容。 例如: 旧地址:/index.php?mod=news & AC =住客评论& ID = 367个 新地址:/用品/ 367

我想在我的.htaccess像添加:

redirectmatch 301 index.php?mod=news&ac=commentaires&id=([0-9]+) http://www.nailissima.fr/articles/$1 

但它不起作用。当我输入旧地址时,它仍然会重定向到主页,而不是相应的文章。

你能帮我解决吗?

这里是我的.htaccess:

# $Id: .htaccess 7539 2010-10-04 04:41:38Z john $ 

<IfModule mod_rewrite.c> 
    Options +FollowSymLinks 
    RewriteEngine On 

    # Get rid of index.php 
    RewriteCond %{REQUEST_URI} /index\.php 
    RewriteRule (.*) index.php?rewrite=2 [L,QSA] 

    # Rewrite all directory-looking urls 
    RewriteCond %{REQUEST_URI} /$ 
    RewriteRule (.*) index.php?rewrite=1 [L,QSA] 

    # Try to route missing files 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} public\/ [OR] 
    RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$ 
    RewriteRule . - [L] 

    # If the file doesn't exist, rewrite to index 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA] 

</IfModule> 

# sends requests /index.php/path/to/module/ to "index.php" 
# AcceptPathInfo On 

# @todo This may not be effective in some cases 
FileETag Size 

预先感谢您!

致以问候

+0

你可以发布你编辑的htaccess你添加规则的地方吗? – Salman

回答

0

可能是您的重定向指令的顺序有问题。

首先停用注释您当前的所有常规规则,然后尝试单独使用新的重定向。

如果他们工作,然后仔细想想你应该把他们放在哪里。

[L]在指令结束时使它最后一个,所以它这条指令匹配,不再进行处理。

使用此方法,先写更详细的说明,稍后再写更详细的说明,否则,当进一步的说明超出当前的范围时,可以满足情况!

+0

谢谢你的快速回答! 不幸的是我试图禁用.htaccess的所有内容,并且只在第一行放置了redirectmatch代码,即使这样也行不通:网站上的很多菜单和链接都被打破了,但是当我输入一个旧地址,它仍然重定向到SocialEngine的主页,而不是相应的新页面:( – Myriam