Shamoon
Shamoon

Reputation: 43491

How do I serve index.html with .htaccess

I have an angular app at someip.com/mysite/

In my .htaccess, I have

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api

RewriteRule ^.*$ - [NC,L]
RewriteRule ^$ /mysite/index.html [NC,L]

Within my angular code, it redirects to someip.com/mysite/reservations/new and Apache tries to look for that instead of just serving index.html

What am I doing wrong?

There's one additional condition.. someip.com/mysite/admin should serve the admin.html page instead of index.html

Upvotes: 0

Views: 197

Answers (2)

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

First comment other rules & try this rule in root directory

DirectoryIndex admin.html index.html

here if there is some directory exist it must contain index.html file and if there is no index.html file or admin.html is present in admin folder it will make admin.html as index of that particular directory.

Upvotes: 2

Amit Verma
Amit Verma

Reputation: 41219

You dont need rewriteRule for this, just use DirectoryIndex directive

DirectoryIndex /index.html

Upvotes: 1

Related Questions