Can anyone tell me why the following visibly changes the URL in the browser, rather than redirecting silently? The redirect works, but visibly.
Example URL: http://domain.com/_test/sportswire/uk/football/huddersfield
...visibily redirects with query string arguments showing.
RewriteEngine on
RewriteBase /_test/sportswire
#favour naked domain over www
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1/$1 [R=301,NE,L]
#disallow trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
###THIS RULE### channel pages - territory/sport/channel/[res type?]
RewriteRule ^(\w+)\/(\w+)\/(\w+)(?:\/(\w+))?$ channel.php?territory=$1&sport=$2&team=$3&res_type=$4 [L,NC,R=301]
#channel pages - with item (if from external referrer) - territory/sport/channel/res_type/"item"/item_id/pretty
RewriteRule ^(\w+)\/(\w+)\/(\w+)\/(\w+)\/story\/\w{11}\/[^\/]+$ channel.php?territory=$1&sport=$2&team=$3&res_type=$4&item=$5 [L,NC,R=301]
What I've tried/read:
- Remove the R flag (no joy; and I have other .htaccess files with R flags that redirect silently)
- Add/remove a rewrite base (done; also tried an absolute one)
- Don't use absolute URLs (I'm not)
I'm fairly convinced there's nothing on planet earth quite as perplexing as mod-rewrite.