How to create date wise apache error log and access log

By default apache write the access log and error log in the single file. Later it grow in sizes over days and then when you have to debug you find the issue from the apache log, it become difficult to open and read the file. And over a time, the log size bigger so big that, many of the file editor fail to load the file.

Default Logformat
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

So apache come with a inbuilt program called rotatelogs.
First you need to check if rotatelogs is present on your server or not.

To check if rotatelogs is present type the below command
> whereis rotatelogs

The output of the command will be as below
rotatelogs: /usr/bin/rotatelogs /usr/share/man/man8/rotatelogs.8.gz

This “/usr/bin/rotatelogs” indicate that rotatelogs program is present

Now to split your errorlog and accesslog by date, you need to comment the default log format
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined

and write down the below format.

CustomLog “| /usr/bin/rotatelogs -l /var/log/apache2/access.%Y.%m.%d.log 86400” common
ErrorLog “| /usr/bin/rotatelogs -l /var/log/apache2/error.%Y.%m.%d.log 86400”

What this does is…everyday a new error log and access log file will be created like error.2020.04.03.log and access.2020.04.03.log respectively.

To explore more option for the custom logging you can refer the apache project page

drupal clean URLs not working? with tilde sign

If your site is developed in Drupal and your URL looks like this:

If your site URL looks like this:

http://[domain name OR IP Address]/~[accountname]/anyFolder/


Then you need to set RewriteBase!in your .htaccess file that looks like below

RewriteBase /~xyzaccount/somefolder

Force HTTPS url with .htaccess

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don’t put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

How to configure the symfony project directory

Your symfony project derectory is “/var/www/html/sf_sandbox” so in the browser you can acess this by this URL : “http://localhost/sf_sandbox/web/frontend.php/”

So if you want to map the symfony project directoy to your web root directory ie i mean to say you just want to acess it my using the URL :”http://localhost/” then you have to add the below line in the httpd.conf file and then restart your apache server.After that you can directly acess the symfony project from localhost url.

<VirtualHost *:80>
ServerName http://localhost/
DocumentRoot “/var/www/html/sf_sandbox/web”
DirectoryIndex index.php
<Directory “/var/www/html/sf_sandbox/web”>
AllowOverride All
Allow from All

Rest of the things will be handled by symfony itself.

How to redirect domain to other directory on the same domain

Open the .htaccess file of your root directory
of your project and add the following line.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^ [NC]
RewriteCond %{HTTP_HOST} !^ [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteCond %{REQUEST_URI} !^/someOtherDirectory/
RewriteRule ^(.*)$ /someOtherDirectory/$1

Then restart your apache

Usage :
Suppose your project is placed in some other directory
other than the default web directory then you can redirect
your request to that directory for example

Your actual project URL is
and you want that your URL should resemble like
then the above .htaccess rule will do the same.