0

I'm currently performing website redirection from non-www to www+https, but unfortunately, my redirection does not work and I've tried to create rewrite log but it ends up my website down. After further check, I found here with below command:

tail -f error_log|fgrep '[rewrite:'

But command above seems to be for UNIX/Linux, my website currently setup under Windows Server. Is there any way I can run this in Windows server? Or is there any other way I can set up custom logs just to show redirection error/issue?

Petri
  • 47
  • 1
  • 10
  • "create rewrite log but it ends up my website down." - what do you mean by this? Are you saying the action of creating a rewrite log brings your website down? What directives are you using to create your log? – MrWhite Mar 31 '20 at 08:58
  • Hi Mr. White, I include this in my httpd-vhosts-conf RewriteEngine On RewriteLog "${INSTALL_DIR}/log/rewrite.log" RewriteLogLevel 6 but after I restart my apache, my website turns out unable to connect. Do I need to add anything else? – Petri Mar 31 '20 at 09:04
  • Those are Apache 2.2 directives - if you are on Apache 2.4 (as stated in your question) then it will indeed break your server. But the Apache docs page you link to already states the directive you should be using, ie. `LogLevel alert rewrite:trace3` (?) – MrWhite Mar 31 '20 at 09:43
  • Although your [other (older) question](https://serverfault.com/questions/1009940/wwwhttps-redirection-does-not-work-even-though-redirection-has-been-added-in-h) would seem to imply you are already doing this correctly?! – MrWhite Mar 31 '20 at 09:47
  • Yes, I did try but with LogLevel alert rewrite:trace6 and I've also posted my logs in here:https://serverfault.com/questions/1009940/wwwhttps-redirection-does-not-work-even-though-redirection-has-been-added-in-h but he mentioned that those logs don't help which I kind of made me helpless or did I misunderstood what he mean??.. – Petri Mar 31 '20 at 09:53
  • "he mentioned that those logs don't help" - Yes, but that's because the logs appear to be for "something else", not related to the directives in your question. – MrWhite Mar 31 '20 at 12:02

1 Answers1

1

This should do the trick using Powershell:

Get-content -Path D:/wamp64/logs/rewrite.logs -wait -tail 10 | select-string -pattern "\[rewrite:"

The components:

Get-Content -Path: This will pull the contents of the file at the specified path.

-wait: This parameter will wait for new lines to be written. Note that you will need to press Ctrl-D to end monitoring of the file.

-tail 10: This will retrieve the last ten lines.

Select-string: This will select the string matching the following pattern.

-pattern: This will get the pattern that you are looking for. The "\" escapes the bracket special character.

Davidw
  • 1,222
  • 3
  • 14
  • 25
  • So the details will show at the log that we point at? Let's say my logs at d:/wamp64/logs/rewrite.logs, how did I do that? Usually done it at CMD, PowerShell kind of less use compared to CMD. – Petri Mar 31 '20 at 05:38
  • I edited with the file path and a more complete explanation. – Davidw Mar 31 '20 at 05:47
  • Hi Davidw, thanks for your explanation. Will try to go through my apache to check again which file I need to pull the content and how it works. :) – Petri Mar 31 '20 at 06:19