phranque

msg:4494933 | 11:06 pm on Sep 13, 2012 (gmt 0) |
you must order your directives from the most specific rule to the most general rule. (are you sure that should be a 302 vs 301?)
|
rwilson

msg:4494946 | 12:13 am on Sep 14, 2012 (gmt 0) |
I meant to have 301, I was just using 302 for testing. So if I just switch the order around and say the most specific first I should be good? RewriteRule ^example/new-stuff/? /new-example/new-stuff/ [R=302,L] RewriteRule ^example/? /new-example/ [R=302,L]
|
phranque

msg:4494961 | 1:43 am on Sep 14, 2012 (gmt 0) |
assuming "example" is the same in both rules, you can actually do that in one rule by capturing the optional subdirectory in the pattern and using the back reference in the target.
|
lucy24

msg:4494967 | 2:27 am on Sep 14, 2012 (gmt 0) |
... and as long as you're there, may as well allow for "index.html" -- or php or whatever it is you really use -- so you can redirect those in the same rule: directory(/(index\.html)?)?$ {et cetera} Otherwise some people will be redirected twice.
|
rwilson

msg:4494968 | 2:28 am on Sep 14, 2012 (gmt 0) |
Cool! "example" is the same, how would I go about doing that?
|
phranque

msg:4495002 | 4:55 am on Sep 14, 2012 (gmt 0) |
you can group something in your pattern by surrounding it with parentheses. when something is captured in a group it can be reused by referring back to it with a variable in the substitution. Back-references are identifiers of the form $N (N=0..9), which will be replaced by the contents of the Nth group of the matched Pattern.: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule
|
|