0

I need some help. I have a small issue. I need if some user enters my domain name in the address bar, for example www.mysite.com, it should redirect to www.mysite.com/abc for example, without requring the user to enter www.mysite.com/abc in the address bar. I am using Opencart version 3.0.2.0. I do not want to install Opencart in subdirectory /abc. www.mysite.com and htaccess file are located in root that is in public_html and subdirectory /abc is not located anywhere, neither in root nor elsewhere. What actually I want is that when user enters www.mysite.com then it should redirect to www.mysite.com/abc and the user should see the same content at www.mysite.com/abc which user would have seen at www.mysite.com. I have tried adding "RewriteRule ^$ /abc [R=301,L]" at the bottom of htaccess. With this code www.mysite.com redirected to www.mysite.com/abc but giving an error "The page you requested cannot be found". How can I solve this through htaacess file or in any other way? I would be thankful for any help.

1 Answers1

0

Redirect only the domain's root URL to a subdirectory

Change mysite to your site name. and yourdirectory to your directory name.

RewriteEngine on
RewriteCond %{HTTP_HOST} mysite\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /yourdirectory/$1 [L]
K. B.
  • 1,388
  • 2
  • 13
  • 25