I am having trouble with redirecting the main domain to a subdirectory without changing the URL.
RewriteCond %{HTTP_HOST} ^kargomastercompanies\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.kargomastercompanies\.com$
RewriteRule ^/?$ "http\:\/\/kargomastercompanies\.com\/kargomastercompanies\.com" [R=301,L]
that's the code written in .htaccess file. What should I do to keep the domain name same as it's in my root directory? Thanks in advance for helping me.
To simply rewrite, without redirecting, you should not use [R=301]
Use:
RewriteCond %{HTTP_HOST} ^(www\.)?kargomastercompanies\.com$ [NC]
RewriteRule !^kargomastercompanies\.com /kargomastercompanies.com%{REQUEST_URI} [NC,NE,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.