RE: Mod_Rewrite voodoo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Reese [mailto:howell.r@xxxxxxxxxxxxxxxx]
> 
> >> I tried:
> >>
> >> RewriteEngine On
> >> RewriteCond %{HTTP_HOST} subdomain\.domain\.ext
> >> RewriteCond %{REQUEST_URI} ^/20\d+
> >> RewriteRule (.*)(0[5-9]).html$ /20$2/$1$2.html [R=301,L]
> >>
> >> For http://subdomain.domain.ext/fileDDMMYY.ext there was no effect,
> >> that file loaded at that URL.
> >
> > I think that condition needs negating, because you want your rule to
> > not have a chance to execute against the rewritten URL that will have
> > the leading date.
> 
> Which condition needs negating? The one with HTTP_HOST? What
> then would keep this rewrite rule from breaking external links
> where they also contain a matching NN.html string?

Reese, you really ought to take a closer look at the mod rewrite directives. A RewriteCond is a condition that must be verified (ie evaluate to TRUE) in order for the associated RewriteRule to be executed. So your 

RewriteCond %{REQUEST_URI} ^/20\d+

will cause

RewriteRule (.*)(0[5-9]).html$ /20$2/$1$2.html [R=301,L]

to be applied ONLY if the URL request starts with /20 followed by at least one digit (/200, /2000, etc). This is clearly the opposite of what you want: you want the rewrite rule to be executed only if the URL request does NOT start with that string. 

Also, why are you concerned with external links? External links, when clicked by user, will go to servers outside of your domain so your server will never see the request. The rewrite module works on the HTTP request to its server, not on the body (HTML) of request responses. 

Oliver


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux