3

How to deploy the build of the angular 5 project in Laravel? I am deploying the build files of angular in Laravel, it is working everything fine but when I refresh after routing to any page is showing 404. The reason is it will check the controller in the backend with that URL. I tried to avoid this problem by using hash strategy but I am thinking it is not a good idea. So please help me resolve this issue.

3

1 Answer 1

1

As mentioned in Angular issue use following .htaccess file to load the same page of angular on refresh.

<IfModule mod_rewrite.c>
    RewriteEngine on

    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Rewrite everything else to index.html
    RewriteRule ^ index.html [L]
</IfModule>

If your index.html file is not in your root folder then you have to change the path of index.html as where your index.html exist,

like my index.html is in resources/views/ then i will write the rule in .htaccess as :

RewriteRule ^ resources/views/index.html [L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.