D. Sean
D. Sean

Reputation: 145

How to solve sub-directory issue on hosting server

I hosted a website to a sub-directory in a hosting server. But it is redirected to the main domain when I try to navigate to the sub-url of the website. So, I added the .htaccess file to solve this problem. The .htaccess file is the following.

RewriteEngine On
Options FollowSymLinks

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]

But I am getting the problem continuously. Please let me know how I can solve it.

Upvotes: 1

Views: 31

Answers (1)

jsstackguru
jsstackguru

Reputation: 74

You can write the following contents to your .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-directory/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sub-directory/index.html [L]
</IfModule>

Upvotes: 2

Related Questions