• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Rewrite.log file - Plesk?

S

Superman859

Guest
How can I turn on or view rewrite.log for Plesk? I'm trying to work with mod_rewrite to figure out what the problem is trying to redirect a subdomain to another directory (another issue with Plesk), and it would help if I could view the rewrite.log file.
 
Where would I put that though with Plesk? Would I put it in /var/www/vhosts/domain/conf/vhost.conf ?

Should I use vhost.conf for basically any Apache changes I make? And that should always go in /var/www/vhosts/domain/conf? Because there is a conf in the subdomains section as well, which is what I'm dealing with. I'm never sure which conf directory I should be putting .htaccess files or vhost.conf files.

Anyways...perhaps I don't even write RewriteLog in that file. Anyone know?
 
The link I mentioned says you can use RewriteLog in both server config (httpd.conf) and virtual host (vhost.conf) context. Take your pick.
 
Hmm...well I tried putting it in vhost.conf but my vhost.conf file doesn't seem to be doing anything... First off, I put

RewriteLog "/var/www/vhosts/domain/statistics/logs/rewrite.log"

in vhost.conf. No logs visible anywhere for it yet even though I'm getting mod_rewrite errors. I've tried putting mod_rewrite rules in vhost.conf as well with no affect (no errors, no changes, nothing). When I copy those same rules to .htaccess, I get the errors, so I know it's at least doing something.

Finally, in Putty none of the text I type in for vhost.conf is color coded, while it is in .htaccess and other files. Just a Putty thing, or is it a sign that vhost.conf isn't configured properly or something strange like that?

But no matter what I put in vhost.conf, I see no changes. I've tried vhost.conf in both

/var/www/vhosts/domain/subdomains/sub/conf/vhost.conf

as well as

/var/www/vhosts/domain/conf/vhost.conf
 
Hey, thanks for that last info. That made the vhost.conf files work (I think). I now have a rewrite.log file showing up, although it's empty and doesn't seem to be getting anything. But I'm getting a 404 error for the redirection now, except I can't figure out what file is telling to to redirect to where it is...lol.

Along the same note, will I have to run that command each time I make a change to vhost.conf or just the first time I begin using it?
 
Hey, thanks for that last info. That made the vhost.conf files work (I think). I now have a rewrite.log file showing up, although it's empty and doesn't seem to be getting anything. But I'm getting a 404 error for the redirection now, except I can't figure out what file is telling to to redirect to where it is...lol.

As long as you don't post your config we can't see what could be the problem. Did you set RewriteEngine on (this is not inherited)? Did you set a RewriteLogLevel (0 by default)? Did you create the logfile yourself or did apache do this? Can apache write to this file?

Along the same note, will I have to run that command each time I make a change to vhost.conf or just the first time I begin using it?

All that websrvmng does in this case is adding an Include vhost.conf to the (sub)domain's httpd.include file. Once you've done that, you don't need to do it again for that (sub)domain. It's smart enough to not add multiple Includes for the same vhost.conf though.
 
Hello. I've managed to get it logging with RewriteLog and RewriteLogLevel 3. It does seem that changes aren't made to the server until I run websrvmng command again - that or it rebuilds the vhost (the second part of that command you provided). So after any changes to vhost.conf, nothing seems to change until I run that command again.

Anyways, they do change if I run it.

Here is the closest I've gotten with the mod_rewrite.

Code:
RewriteEngine On
RewriteRule ^(.*)? [url]http://www.domain.com/testsub[/url]$1? [NC,L]

I've left out the RewriteLog details, but that works fine.

What I have above effectively redirects anything from the subdomain to the folder testsub. It seems to do what I need it to do.

The only problem is it does so and changes the URL in the browser - I want it to keep the old (fake) URL in the browser and just bring up the files from the other directory, which mod_rewrite can do. I think it changes the URL because I'm using an absolute URL request when I do the rewrite. It's the only way I've been able to get it to rewrite so far without any errors generated.
 
I've managed to get it logging with RewriteLog and RewriteLogLevel 3. It does seem that changes aren't made to the server until I run websrvmng command again - that or it rebuilds the vhost (the second part of that command you provided). So after any changes to vhost.conf, nothing seems to change until I run that command again.

Anyways, they do change if I run it.

You don't need to run websrvmng again, you have to reload your apache config after you change it. Websrvmng *also* reloads your apache config, that's why it works, but you could just run 'service httpd reload' (or /etc/init.d equivalent if you run a distribution that doesn't support the service command).

Here is the closest I've gotten with the mod_rewrite.

Code:
RewriteEngine On
RewriteRule ^(.*)? [url]http://www.domain.com/testsub[/url]$1? [NC,L]

I've left out the RewriteLog details, but that works fine.

What I have above effectively redirects anything from the subdomain to the folder testsub. It seems to do what I need it to do.

The only problem is it does so and changes the URL in the browser - I want it to keep the old (fake) URL in the browser and just bring up the files from the other directory, which mod_rewrite can do. I think it changes the URL because I'm using an absolute URL request when I do the rewrite. It's the only way I've been able to get it to rewrite so far without any errors generated.

I think I would solve this in a different way. If you create a wildcard DNS A record for your main domain there is no need to actually create the subdomains in Plesk. You could then set 'ServerAlias *.domain.com' in your vhost.conf and rewrite subdomain.domain.com/directory to domain.com/subdomain/directory. You might want to check http://forum.modrewrite.com/ for the exact syntax for that.
 
Back
Top