The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> .htaccess redirection fail
rpizw
post Mar 5 2020, 08:11 AM
Post #1





Group: Members
Posts: 2
Joined: 5-March 20
Member No.: 27,218



Hi all,

I'm trying to redirect two simple websites and it just doesn't work! I tried for two days and search so much but nothing

I created .htaccess in /var/www/html/ with the following

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

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


the first time is working but not the second sad.gif
anyone?

Thanks in advance.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 5 2020, 08:46 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



I'm actually not sure if it's necessary, but do you have 'RewriteEngine on' on top of that?

QUOTE
the first time is working but not the second sad.gif


Do you mean firstexample works but not secondexample? Or do you mean it works the first time you go to that URL but not the second?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
rpizw
post Mar 5 2020, 09:23 AM
Post #3





Group: Members
Posts: 2
Joined: 5-March 20
Member No.: 27,218



sorry about not being clear.

firstexample website work perfectly
second example website never worked. i just see loops in the URL or when I try other things I only get into the root folder from my browser sad.gif

So
just so I can be clear as possible, below is how I configured it ---> noticed that I removed the "secondexample" website just because it cause some crushes on my server for some reason..

from /etc/apache2/sites-available/000-default.conf
CODE

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/

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

RewriteEngine on

RewriteCond %{SERVER_NAME} =firstexample.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

<Directory /var/www/html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
</Directory>

---
From /vart/www/html/.htaccess (which I created)
CODE

Options +FollowSymLinks
RewriteEngine on

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

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 5 2020, 09:01 PM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



QUOTE(rpizw @ Mar 5 2020, 03:23 PM) *

noticed that I removed the "secondexample" website just because it cause some crushes on my server for some reason..


So something is fishy with secondexample? unsure.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th April 2024 - 02:58 PM