Welcome to WebmasterWorld Guest from 54.156.56.73

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

htaccess redirect question

redirect entire directory except one file

     
12:01 pm on Nov 6, 2013 (gmt 0)

Preferred Member

5+ Year Member

joined:Dec 19, 2007
posts: 404
votes: 0


Hi
Just trying to figure how to write a redirect 410 for an entire directory except for a single file that is to be 301'd to a new location.

tx.
10:45 pm on Nov 6, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10887
votes: 72


first, a RewriteRule with the [R=301,L] flag to handle the more specific file redirect.
then, a separate RewriteRule using the [G] flag to provide the 410 status code for the more general directory case.
10:54 pm on Nov 6, 2013 (gmt 0)

Preferred Member

5+ Year Member

joined:Dec 19, 2007
posts: 404
votes: 0


does that L flag stop any rules from running or just the next rewrite rule? tx.
12:26 am on Nov 7, 2013 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10887
votes: 72


http://httpd.apache.org/docs/current/rewrite/flags.html#flag_l
The [L] flag causes mod_rewrite to stop processing the rule set.

it's more complicated than that, so you should really read and understand the entire section.
1:13 am on Nov 7, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13828
votes: 484


does that L flag stop any rules from running or just the next rewrite rule? tx.

Each module is an island. So even if mod_rewrite has already handed out a decisive 403, all the other mods still have to run.

Ordinarily you list rules in order of severity, so a 410 would come before a 301. But sometimes-- like here-- it's more practical to put some rules out of sequence.