Page 1 of 1

Redirect Subdirectory to Main website

Posted: Sat Mar 31, 2018 3:16 am
by mminten
I am trying to redirect an entire subdirectory (/dev/) to our main domain (https://garrysun.com/).

Basically links like this:
Should all go to:
We are using OpenCart 2.3.0.2

I have tried:

Code: Select all

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/dev/(.*)$
RewriteRule ^(.*) https://garrysun.com/ [R=301,NC]
and

Code: Select all

RewriteRule ^dev/(.*)$ https://garrysun.com [R=301,NC,L]
These were all in the website's .htaccess file in the main directory. I also tried adding:

Code: Select all

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?garrysun\.com$ [NC] 
RewriteRule ^ https://garrysun.com/? [R=301,L]
In a .htaccess file by itself in the /dev/ directory. None of these options are working.

What is the best .htaccess rule to make this work?

Re: Redirect Subdirectory to Main website

Posted: Sat Mar 31, 2018 9:07 am
by IP_CAM
OpenCart Community - Forum OpenCart 1.5+ - Support General Support ::)

Re: Redirect Subdirectory to Main website

Posted: Sun Apr 01, 2018 3:08 am
by victorj
you could try this one.
it should be located in your .htaccess id folder /dev/

Code: Select all

RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ https://garrysun.com/$1 [R=301,L]

Re: Redirect Subdirectory to Main website

Posted: Sat Apr 14, 2018 6:48 am
by mminten
I tired this but it doesn't quite work, it does take out the /dev/ but it keeps the rest of the link there.

For example: https://garrysun.com/dev/index.php?rout ... y&path=122

redirects to: https://garrysun.com/dev/index.php?rout ... y&path=122

I want it to redirect to: https://garrysun.com/

Is there a way to do this with .htaccess?