简体   繁体   English

301 joomla .htaccess重定向

[英]301 joomla .htaccess redirect

We updated Joomla 1.5 to 2.5 and a lot of links changed so we are doing 301 redirect in the htaccess; 我们将Joomla 1.5更新为2.5,并更改了许多链接,因此我们在htaccess中执行301重定向; however i'm running into a bunch that are just not working. 但是我遇到了很多无法正常工作的情况。

redirect 301 /photos-a-movies/photos-of-old-friends/119-halloween/detail/946-604a927.html?tmpl=component http://www.handicappedpets.com/photos-a-movies/media-photos.html
redirect 301 /photos-a-movies/photos-of-old-friends/101-friends/detail/671-dcp0062.html?tmpl=component http://www.handicappedpets.com/photos-a-movies/media-photos.html
redirect 301 /photos-a-movies/photos-of-old-friends/101-friends/detail/1286-barks.html?tmpl=component http://www.handicappedpets.com/photos-a-movies/media-photos.html

Maybe its catching up on the crap at the end of the url? 也许在网址末尾赶上了垃圾? Either way...is there a way to 301 redirect say "/photos-a-movies/photos-of-old-friends" and no matter what is after it it gets redirected to a page? 无论哪种方式...都有一种方法可以将301重定向说“ / photos-a-movies / photos-of-old-friends”,无论重定向到页面后是什么? Or is there a reason why these 301's don't work? 还是有这些301无效的原因?

EDIT: 编辑:

ok I can get it to work if I do: 好吧,如果我这样做,我可以使它工作:

redirect 301 /photos-a-movies/photos-of-old-friends/101-friends/detail/1286-barks.html http://www.handicappedpets.com/photos-a-movies/media-photos.html

Instead of 代替

redirect 301 /photos-a-movies/photos-of-old-friends/101-friends/detail/1286-barks.html?tmpl=component http://www.handicappedpets.com/photos-a-movies/media-photos.html

Redirects to http://www.handicappedpets.com/photos-a-movies/media-photos.html?tmpl=component but it places the "?tmpl=component" at the end still. 重定向到http://www.handicappedpets.com/photos-a-movies/media-photos.html?tmpl=component但它将“?tmpl = component”放在最后。 Is there a way to get rid of it? 有办法摆脱它吗?

The reason why your original redirects didn't work is because you can't match against the query string (the ?tmpl=component part of the URI) in a Redirect directive. 原始重定向无效的原因是,您无法与Redirect指令中的查询字符串(URI的?tmpl=component部分)进行匹配。

but it places the "?tmpl=component" at the end still. 但是它将“?tmpl = component”放置在最后。 Is there a way to get rid of it? 有办法摆脱它吗?

You need to add a ? 您需要添加一个? at the end of the target URL: 在目标URL的末尾:

http://www.handicappedpets.com/photos-a-movies/media-photos.html?

The problem with that is after the redirect, you have a stray ? 问题是重定向后,您有一个迷路? at the end. 在末尾。 If you can't have that, then you'll need to use mod_rewrite instead: 如果没有,那么您将需要使用mod_rewrite:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^tmpl=component$
RewriteRule ^/photos-a-movies/photos-of-old-friends/101-friends/detail/1286-barks.html$ http://www.handicappedpets.com/photos-a-movies/media-photos.html? [L,R=301]

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

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