TheForbidden
TheForbidden

Reputation: 1573

Angular7 rewrite with apache not working correctly

I have my angular application 7.1.4 running on apache 2.4.10 server. I use PathLocationStrategy to route my urls.

Here is a glimpse at my index.html file

<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Cache-control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0" />
<title>Intranet</title>
<base href="/">

.htaccess file

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ - [L]

RewriteRule ^ /index.html [L]

The problem is, if my URL looks like

http://intranet.company.com/app/myspace?id=favorites

Apache redirects to

http://intranet.company.com/index.html?id=favorites

and my target page is not shown.

How can I solve this knowing that my URLs starts all with BASE_URI/app/...

Upvotes: 0

Views: 661

Answers (1)

Shashan Sooriyahetti
Shashan Sooriyahetti

Reputation: 878

Remove / infront of index.html

   RewriteRule ^ index.html [L]

Upvotes: 0

Related Questions