Forum Moderators: phranque

Message Too Old, No Replies

Redirect 301Question

.htaccess redirect

         

keyplyr

7:19 am on May 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




This redirects requests for a now defunct directory to the index page:

Redirect 301 /dircetory_name/ [domain.com...]

How can I modify this to also include requests for: /dircetory_name (without the trailing slash)? Thanks

mack

7:34 am on May 14, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



hi keyplyr,
If you use this

/directory_name(.*)

This will remove the trailing slash and will also send any users who request files within the directory to go to your new content location. so you could use...

RedirectMatch permanent ^/directory_name(.*) [domain.com...]

That should work ok.

Mack.

keyplyr

8:02 am on May 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Mack, worked great.

I added it next to another redirect:

RedirectMatch (.*)\.file_type [domain.com...]

How would I change this one to have the same form, or doesn't it matter? (Just thought it would be better to keep the language similiar.)

keyplyr

6:31 pm on May 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



anyone?

mack

6:55 pm on May 14, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi again.

Not sure exactly what you are trying to do with the second example. :)

I think youre trying to specify that all files within the directory go to the domain is this correct.

The snipped I used in my above post shoudl be up to the job.

General I use that method when I hange a directory name or location, Either pass users to the homepage if the directory no longer exists or to the new location and directry name.

Sorry if I picked your post up wrong. If so feel free to try me again :)

Mack.

keyplyr

7:34 pm on May 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi mack,

In the past, I had a certain file_type that was located from several directories. I have removed this file_type, but 2 years later I still see dozens of requests in my error logs. This redirect sucessfully sent these requests to my home page, instead of my error page:

RedirectMatch (.*)\.file_type [domain.com...]

My question was, should I change it to a similiar syntax as the code you suggested above? My thinking is that all RedirectMatch rules should follow similiar language. Thanks.

mack

2:08 am on May 15, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi again keyplyr.
In the past I have used htaccess files with different syntax and to be honest I didnt have any problems with it. It just looks a lot easier on the eye if they all follow a set patern.

Mack.

jdMorgan

2:33 am on May 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



keyplr,

To "standardize" the syntax and get rid of a few unnecessary characters:


RedirectMatch permanent ^/directory_name http://www.domain.com/
RedirectMatch permanent \.file_type$ http://www.domain.com/

Jim

keyplyr

3:21 am on May 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Excellent, works perfect. Thanks Jim

Since 301 translates to "permanent", wouldn't this also be correct?

RedirectMatch 301 ^/directory_name [domain.com...]
RedirectMatch 301 \.file_type$ [domain.com...]

jdMorgan

3:49 am on May 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes,

same-same.

Jim