简体   繁体   English

如何使用.htacces重定向到特定路径?

[英]How to redirect to specific path with .htacces?

Im writing Redirect Rule and came up on a problem that could interest some of you. 我正在编写“重定向规则”,并提出了您可能会感兴趣的问题。

The idea is to redirect old path voyage/grece/mykonos/ to new path voyage/cyclades/mykonos/ 这个想法是将旧路径voyage/grece/mykonos/重定向到新路径voyage/cyclades/mykonos/

But whatever i tried failed and redirect me to strange url :/ -> 但是我尝试失败的一切,然后将我重定向到奇怪的URL:/->

http://www.agencedevoyage.com/voyage/europe/cyclades/mykonos/?continent=europe&country=grece&town=mykonos&type=voyage

Does that mean the php traitement is done without refreshing the page or something like that ? 这是否意味着php特性完成后无需刷新页面或类似内容? How can I avoid this ? 如何避免这种情况?

Rules I tried : 我尝试过的规则:

ReWriteRule \/voyage\/europe\/grece\/mykonos\/  http://www.agencedevoyage.com/voyage/europe/cyclades/mykonos/ [R=301,L]

RedirectPermanent /voyage/europe/grece/mykonos/ http://www.agencedevoyage.com/voyage/europe/cyclades/mykonos/

Try this 尝试这个

RewriteRule ^/voyage/europe/grece/mykonos/$ http://www.agencedevoyage.com/voyage/europe/cyclades/mykonos/ [R=301,L]

Or 要么

Redirect 301 /voyage/europe/grece/mykonos/   http://www.agencedevoyage.com/voyage/europe/cyclades/mykonos/

Make sure that the opening of the .htaccess file contains the 2 lines of code below which enables the Apache module to rewrite the URLS, then place your redirections below them 确保.htaccess文件的打开包含下面的两行代码,这些代码使Apache模块可以重写URL,然后将重定向放置在它们下面

Options +FollowSymLinks
RewriteEngine On

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM