2012-04-07 50 views
0

总之,我们目前遇到了我们的htaccess文件问题。 301重定向到达新的描述的URL,但此外,新的URL后面跟着一个?和旧的网址。我们如何摆脱?和以前的网址,因此它们不会显示为结尾。如何防止旧的URL和?通过htaccess包含在301重定向的URL中

我们在网上发现这个问题的例子都没有出现。任何人都可以请提供一些建议?我们可以使用RewriteRule来阻止这种情况的发生吗?

这里的htaccess文件

# begin redirects 
# There are redirects of a number of old pages. Here's a sample of them. 

redirect 301 /index.html http://www.petersommer.com/ 
redirect 301 /escorted-archaeological-tours/turkey/western-lycia-cruise-july/ http://www.petersommer.com/escorted-archaeological-tours/ 

RewriteRule ^gallery/main.php$ http://www.petersommer.com/gallery/ [R=301,L] 
RewriteRule ^pdf/how_to_book.pdf$ http://www.petersommer.com/pdf/how-to-book-holiday.pdf [R=301,L] 

# end redirects 

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    Options +FollowSymLinks 
    DirectoryIndex index.php 
    RewriteEngine On 

    RewriteCond $1 !^(images|system|themes|pdf|favicon\.ico|robots\.txt|index\.php) [NC] 
    RewriteRule ^\.htaccess$ - [F] 

    RewriteRule ^favicon\.ico - [L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php?/$1 [L] 
</IfModule> 

DirectoryIndex index.php 

的总结不幸的是我不知道什么是不工作或需要做的事情,以解决它。我认为它必须是重写规则中的某些内容,或者我们需要添加一些重写规则来修复它。

不幸的是,所有的重定向添加?并将旧网址添加到新的重定向网址的末尾。因此,例如:

通到/escorted-archaeological-tours/?/tours2006.html ,而不是仅仅/escorted-archaeological-tours/

重定向 /escorted-archaeological-tours/ 去所有都遵循同样的模式 - 很遗憾。

如果您可以在重写规则中看到任何故障或可以识别需要添加的内容,我将非常感激。

回答

0

正如您可能已经注意到的那样,表示为RewriteRule的两个重定向按预期工作,而两个redirect指令附加旧路径。

我相信会发生什么

  • mod_rewrite的踢,如果需要重定向gallery/main.phppdf/how_to_book.pdf,然后每隔URL重写为/index.php?/the_requested_path,结束那里(将L标志)。请注意查询参数

  • mod_alias轮到了,看到它必须重定向/index.html,例如,按照指示重定向。但是,在默认情况下,重定向的Apache附加了查询参数,在这种情况下?/index.html

你能做些什么

  • 追加?在重定向指令的结束(适用于重写规则,对重定向未测试)

    redirect 301 /index.html http://www.petersommer.com/? 
    
  • 将您重定向指令在重写规则

    RewriteRule ^index.html$ http://www.petersommer.com/ [R=301,L] 
    RewriteRule ^escorted-archaeological-tours/turkey/western-lycia-cruise-july/?$ http://www.petersommer.com/escorted-archaeological-tours/ [R=301,L] 
    
+0

非常感谢你的努力帮助。不幸的是,我仍然无法完成工作。你会改变文件中的顺序吗?还有其他建议吗?感谢您的意见。祝好,彼得 – petersommer 2012-04-09 11:39:00

+0

@petersommer我刚刚在您的网站上检查了/index.html,重定向按预期工作。也许缓存问题?还是你找到另一种解决方案? – nikoshr 2012-04-11 16:22:24

相关问题