Similiar to issue found here.
Running debian, apache2, trying to redirect example.org.com
to example.org.com/aplication/calculator
. I have enabled mod_rewrite hence why IP redirect works.
However if I put in different condition into .htaccess
file located in my /var/www/html
directory and type in the URL address it proceeds to normal https://example.org.com
page. The .htaccess
file itself contains following:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^123\.456\.789\.0$
RewriteRule ^(.*)$ https://example.org.com/ [R]
RewriteCond %{HTTP_HOST} ^example\.org\.com$
RewriteRule ^(.*)$ https://example.org.com/aplication/calculator [R]
Similarly to issue I have found here previously, tried the apachectl -S
command and the output looks so:
VirtualHost configuration:
*:443 example.org.com (/etc/apache2/sites-enabled/000-default-le-ssl.conf:5)
*:80 example.org.com (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33
I have tried creating example.org.com.conf
file in /etc/apache2/sites-enabled
folder, then through symlink connecting it with file in /etc/apache2/sites-available
similiarly to 000-default.conf
file (which to my knowledge causes the IP redirect to work) and putting in AllowOverride all, but it still doesn't seem to have any effect. Thank you for reading.
EDIT: Although specified in my virtual host (AllowOverride all
), changed to all also in /etc/apache2/apache.conf file
for same folder as suggested here although not recommended. Now it redirects me, but puts me on a redirect loop.
000-default.conf
. Leave it as is and create new conf files for each site. Steps 3 and 4 of this guide will walk you through the process: digitalocean.com/community/tutorials/…/etc/apache2/sites-available/example.org.com.conf
and then runa2ensite example.org.com.conf
(to deactivate runa2dissite 000-default.conf
)