I tried and tried but failed to redirect using .htaccess

Alles, was den Apache betrifft, kann hier besprochen werden.

I tried and tried but failed to redirect using .htaccess

Postby rpizw » 05. March 2020 13:49

Hi all,
I'm new here

I tried for over two days and searched, googled... I almost gave up

it's a debian 10 running apache2 and I simply want to redirect 2 websites

example1.com to example1.com/drupal with HTTPS -->works
example2.com to example2.com/oldhtml --> not working (no need HTTPS for now)

here is what I put on .htaccess I created inside: /var/www/html folder:

RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ http://example.com/drupal/$1 [R=301,L]

Thanks in advance.
rpizw
 
Posts: 1
Joined: 05. March 2020 13:44
XAMPP version: 2
Operating System: macos

Re: I tried and tried but failed to redirect using .htaccess

Postby Nobbie » 06. March 2020 10:41

I cannot see any rule for example1.com nor for example2.com, neither any rewrite to oldhtml. That .htaccess obviously does not solve any problems, as it affects example.com only, which is not given here. I really wonder that it should work for example1.com, there is no rule for example1.com.

You also should insert a condition if the URL already contains "drupal" (or "oldhtml" in case of example), then do not redirect, otherwise you will get an infinite loop of redirections.
Nobbie
 
Posts: 11467
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 0 guests