views:

67

answers:

1

I have the following redirects in my htaccess file

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

The first two redirects work perfectly, but the last two are not.

When to go domain.com/communityed/visit/index.htm it redirects it to domain.com/community_education/visit/index.htm, but it should go to domain.com/directions

Same thing the 4th redirect as well

http://domain.com/communityed/visit/pdfs/campus%5Fmap.pdf redirects to http://www.domain.com/community%5Feducation/visit/pdfs/campus%5Fmap.pdf, when it should really go to http://www.domain.com/images/uploads/pdf/campusmap.pdf

What am I doing wrong that the last 2 redirects are not working appropriately?

I imagine it has something to do w/ the first two redirects over-riding it, but I am fairly new to redirects.

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]
A: 

Given that your redirects are not standard mod_rewrite looking, I'll assume that the matches are greedy, therefore you should change the odder from finest match to most general.

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
Simeon Pilgrim