Why won't these rules work?
8 posts
• Page 1 of 1
Why won't these rules work?
URL is http://members.domain.com/members/somefile.htm
RewriteCond %{HTTP_HOST} ^(\w*admin|members|cfajax)\..*$ [NC]
RewriteRule ^(?:/%1)?(.*)$ /%1$1 [L]
%1=members
(?:/%1)? should match "/members" which would cause $1=/somefile.htm
but (?:/%1)? isn't matching "/members"
RewriteCond %{HTTP_HOST} ^(\w*admin|members|cfajax)\..*$ [NC]
RewriteRule ^(?:/%1)?(.*)$ /%1$1 [L]
%1=members
(?:/%1)? should match "/members" which would cause $1=/somefile.htm
but (?:/%1)? isn't matching "/members"
Re: Why won't these rules work?
I tried the following as well with no success
RewriteCond %{HTTP_HOST} ^(\w*admin|members|cfajax)\..*$ [NC]
RewriteCond %{REQUEST_URI} ^(?:/%1)?(.*)$
RewriteRule ^.*$ /%1%2 [L]
RewriteCond %{HTTP_HOST} ^(\w*admin|members|cfajax)\..*$ [NC]
RewriteCond %{REQUEST_URI} ^(?:/%1)?(.*)$
RewriteRule ^.*$ /%1%2 [L]
Re: Why won't these rules work?
Please try the following:
RewriteCond %{HTTP_HOST} ^(admin|members|cfajax)\..*$ [NC]
RewriteCond %{REQUEST_URI} ^/%1(.*)$
RewriteRule .? /%1%2 [L]
If it doesn't work, please clarify which URL this rule should lead to.
And provide rewrite.log records for the test request.
RewriteCond %{HTTP_HOST} ^(admin|members|cfajax)\..*$ [NC]
RewriteCond %{REQUEST_URI} ^/%1(.*)$
RewriteRule .? /%1%2 [L]
If it doesn't work, please clarify which URL this rule should lead to.
And provide rewrite.log records for the test request.
Re: Why won't these rules work?
The point is to have /%1 be optional and stripped off if it is present, but to have the rewrite occur either way.
It worked in version 2 with these rules:
RewriteCond Host: (admin|members|cfajax)\.(?:.*)
RewriteRule (?:/\1)?(.*) /$1$2 [I,L]
It worked in version 2 with these rules:
RewriteCond Host: (admin|members|cfajax)\.(?:.*)
RewriteRule (?:/\1)?(.*) /$1$2 [I,L]
Re: Why won't these rules work?
Both http://members.domain.com/members/somefile.htm and http://members.domain.com/somefile.htm should generate a rewrite of /members/somefile.htm.
Basically we use a system that translates subdomains into subfolders, but some of the code is third-party and generates relative links that include the subdomain/subfolder, the rule is meant to prepend the subdomain to the path but also to strip off the matching subfolder if it is present.
It is just a little disappointing that something that was simple in version 2 seems to not work at all in version 3.
Basically we use a system that translates subdomains into subfolders, but some of the code is third-party and generates relative links that include the subdomain/subfolder, the rule is meant to prepend the subdomain to the path but also to strip off the matching subfolder if it is present.
It is just a little disappointing that something that was simple in version 2 seems to not work at all in version 3.
Re: Why won't these rules work?
Ok, thanks for exaplaining the idea.
Let's try to make it working like this:
RewriteCond %{HTTP_HOST} ^(admin|members|cfajax)\..+ [NC]
RewriteRule ^(?:/\1)?(.*) /%1$1 [L]
And if it still doesn't work, please enable logging in httpd.conf by putting:
RewriteLogLevel 9
and provide rewrite.log records for the test request you make.
Let's try to make it working like this:
RewriteCond %{HTTP_HOST} ^(admin|members|cfajax)\..+ [NC]
RewriteRule ^(?:/\1)?(.*) /%1$1 [L]
And if it still doesn't work, please enable logging in httpd.conf by putting:
RewriteLogLevel 9
and provide rewrite.log records for the test request you make.
Re: Why won't these rules work?
Still not working, can't turn on the logging atm though due to traffic making the file explode in seconds, and way to do it for just one site?
My understanding is the rewrite rule regex is checked 1st then the RewriteConds in version 3, which means \1 wouldn't be anything because the RewriteCond hadn't been processed yet.
Also is it normal for error.log to have lines like "[7/8/2015 11:57:22] ISAPI Filter loaded. Version 3.1.0.112. Windows 6.3 (Build 9600 ServicePack:0) ProductType SERVER. CPU type AMD64 NumberOfProcessors 4" every couple of minutes?
My understanding is the rewrite rule regex is checked 1st then the RewriteConds in version 3, which means \1 wouldn't be anything because the RewriteCond hadn't been processed yet.
Also is it normal for error.log to have lines like "[7/8/2015 11:57:22] ISAPI Filter loaded. Version 3.1.0.112. Windows 6.3 (Build 9600 ServicePack:0) ProductType SERVER. CPU type AMD64 NumberOfProcessors 4" every couple of minutes?
Re: Why won't these rules work?
Hello,
Please try this syntax:
RewriteCond %{HTTP_HOST}#%{REQUEST_URI} ^(admin|members|cfajax)\.[^#]+#.*\1(.*) [NC]
RewriteRule .? /%1%2 [L]
"Also is it normal for error.log to have lines like "[7/8/2015 11:57:22] ISAPI Filter loaded. Version 3.1.0.112. Windows 6.3 (Build 9600 ServicePack:0) ProductType SERVER. CPU type AMD64 NumberOfProcessors 4" every couple of minutes?"
- yes, this is OK
Please try this syntax:
RewriteCond %{HTTP_HOST}#%{REQUEST_URI} ^(admin|members|cfajax)\.[^#]+#.*\1(.*) [NC]
RewriteRule .? /%1%2 [L]
"Also is it normal for error.log to have lines like "[7/8/2015 11:57:22] ISAPI Filter loaded. Version 3.1.0.112. Windows 6.3 (Build 9600 ServicePack:0) ProductType SERVER. CPU type AMD64 NumberOfProcessors 4" every couple of minutes?"
- yes, this is OK
8 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests