I've been asked to put some redirects in place on our server that will forward all of these to one location:
- domain.com/item
- domain.com/item/
- domain.com/item.html
- domain.com/item.html/
- domain.com/category/item
- domain.com/category/item/
- domain.com/category/item.html/
These should all go to domain.com/category/item.html however everything I try seems to end up in an infinite loop. Please help!
This is what I have so far:
Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domin\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/item?$ /category/item.html [L,R=301]
RewriteRule ^category/trafalgar/?$ /category/item.html [L,R=301]
RewriteRule ^category/trafalgar.html/?$ /category/item.html [L,R=301]
RewriteRule ^item?$ /category/item.html [L,R=301]
RewriteRule ^item/?$ /category/item.html [L,R=301]
RewriteRule ^item.html?$ /category/item.html[L,R=301]
RewriteRule ^item.html/?$ /category/item.html [L,R=301]
The 301s are actually 302s in my tests so I don't permanently send myself to the wrong place. The problem appears to be that item always matches, irrespective of whether category preceeds it or not. I'm not entirely sure how to deal with that as it's never been a requirement before.
Any help please?
Bookmarks