【问题标题】:SocialEngine - 301 redirection of old site pages .htaccessSocialEngine - 旧网站页面 .htaccess 的 301 重定向
【发布时间】:2012-05-15 07:44:09
【问题描述】:

我安装了 SocialEngine 来替换旧的 CMS。问题是搜索引擎中存在许多旧 URL。我想将它们重定向到当前网站的相应网址(因为此时它们只重定向到首页)。

我的旧 CMS 的所有内容都已导入 SE,因此每个旧页面现在都有对应的内容。 例如 : 旧地址:/index.php?mod=news&ac=commentaires&id=367 新地址:/articles/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

提前谢谢你!

最好的问候

【问题讨论】:

  • 您可以在添加规则的地方发布您编辑的 htaccess 吗?

标签: .htaccess redirect socialengine


【解决方案1】:

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

首先用 cmets 禁用所有当前的一般规则,然后单独尝试新的重定向。

如果它们有效,请仔细考虑应该将它们放置在哪里。

指令末尾的[L]使其最后,因此该指令匹配,不会进一步处理。

使用这个,先写更详细的指令,然后再写更通用的指令,否则,你可能会遇到进一步指令覆盖当前的情况!

【讨论】:

  • 感谢您的快速回答!不幸的是,我试图禁用 .htaccess 的所有内容,并且只将重定向匹配代码放在第一行,即使这样也不起作用:该站点的许多菜单和链接都已损坏,但是当我输入旧地址时,它仍然重定向到 SocialEngine 的主页而不是相应的新页面 :(
猜你喜欢
  • 2012-10-11
  • 1970-01-01
  • 2012-12-17
  • 2013-06-05
  • 2017-09-21
  • 2013-02-21
  • 1970-01-01
  • 2013-01-04
  • 2017-01-08
相关资源
最近更新 更多