Kaker
Kaker

Reputation: 645

Angularjs: Remove # from url error: 500 Internal Error

Hello I removed the # in the url and it's good, but as I refresh the page I get an error:

500 Internal Error

The server encountered an internal error and could not complete your request.

I have set in the app.config:

$locationProvider.html5Mode(true);

in index.html:

<head>
<base href="/">
</head>

and in .htaccess:

RewriteEngine On
Options FollowSymLinks

RewriteBase /

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

How to fix it?

Upvotes: 0

Views: 404

Answers (1)

reachtokish
reachtokish

Reputation: 356

At first I'm telling you that this is the same problem which I had faced some days ago. In the following there is a couple of steps which you have to maintain

step 1: you have to set base url like after starting the head tag in the top of your main index file. If you are not in the root then you have to set the path as follows

step 2: your .htacces file will be this

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /your-folder-name-here-if-you-are-not-in-the-root/index.html

step 3: in app.config where you set your route there paste this code

$locationProvider.html5Mode(true);

I think that's it

Upvotes: 2

Related Questions