Home > Mobile >  Apache Virtualhost Redirect in specific folders
Apache Virtualhost Redirect in specific folders

Time:12-07

My problem is to redirect in specific folders:

First: all http://myDomain.de must change to https://myDomain.de ... that´s not the problem When the call is: https://myDomain.de/kd i can redirekt to https://myDomain.de/kd/ ..that´s work

My problem is:

when i call : https://myDomain.de i wont to redirect in the folder https://myDomain.de/sub1 (here are my wordpress files...)

here my code:

<VirtualHost *:80>
    Redirect permanent  /kd https://myDomain.de/kd/ 

    Redirect permanent  /   https://myDomain.de/sub1/
</VirtualHost>

<VirtualHost _default_:443>
    ServerAdmin [email protected]
    ServerName myDomain.de
    
    DocumentRoot /var/www/html
    

    ErrorLog ${APACHE_LOG_DIR}/myDomain.de-error.log
    CustomLog ${APACHE_LOG_DIR}/myDomain.de-access.log combined

    <IfModule mod_ssl.c>
        SSLCertificateFile /etc/letsencrypt/live/myDomain.de-0001/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/myDomain.de-0001/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
    </IfModule>

</VirtualHost>


<Directory "/var/www/html">
    Options -Indexes  FollowSymLinks  MultiViews
    AllowOverride All
    Require all granted
</Directory>

CodePudding user response:

Replace your both Redirects with this :

RewriteEngine On

RewriteRule %{REQUEST_URI} !/kd
RewriteRule ^/?$ https://myDomain.de/sub1/ [R=301,L]

CodePudding user response:

Thank you very much! Its works!

Many greetings from Germany!

  • Related