我的htaccess文件中有以下重定向
Redirect 301 /communityed/index.htm http://www.domain.com/community_education
Redirect 301 /communityed http://www.domain.com/community_education
Redirect 301 /communityed/visit/index.htm http://www.domain.com/directions/
Redirect 301 /communityed/visit/pdfs/campus_map.pdf http://www.domain.com/images/uploads/pdf/campusmap.pdf
前两个重定向工作完美,但最后两个不是。
何时访问domain.com/communityed/visit/index.htm,请将其重定向到domain.com/community_education/visit/index.htm,但应该转到domain.com/directions
同样的第4次重定向
http://domain.com/communityed/visit/pdfs/campus_map.pdf重定向到http://www.domain.com/community_education/visit/pdfs/campus_map.pdf,它应该真正转到http://www.domain.com/images/uploads/pdf/campusmap.pdf
我最后2次重定向无法正常工作,我做错了什么?
我认为它有一些事情要做,前两个重定向覆盖它,但我对重定向是相当新的。
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain.com/.*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
答案 0 :(得分:0)
鉴于您的重定向不是标准的mod_rewrite,我会假设匹配是贪婪的,因此您应该将奇数从最精细的匹配更改为最常见的。
Redirect 301 /communityed/visit/pdfs/campus_map.pdf http://www.domain.com/images/uploads/pdf/campusmap.pdf
Redirect 301 /communityed/visit/index.htm http://www.domain.com/directions/
Redirect 301 /communityed/index.htm http://www.domain.com/community_education
Redirect 301 /communityed http://www.domain.com/community_education