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.
Asked
Active
Viewed 84 times
0
-
try this: https://stackoverflow.com/questions/20847256/htaccess-redirect-domain-to-subdirectory-without-changing-url – K. B. Sep 10 '19 at 07:48
-
Sorry I have tried all the stuff provided in this post but it did not work. – Arslan Khan Sep 10 '19 at 08:59
-
have you changed file name from .htaccess.txt to .htaccess ? By default OpenCart has .htaccess.txt. – K. B. Sep 10 '19 at 09:39
-
Yes I have changed .htaccess.txt to .htaccess – Arslan Khan Sep 10 '19 at 10:24
1 Answers
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