Skip to main content

Posts

Showing posts with the label .htaccess

SOLUTION- Angular 404 Not Found error on refresh or redirect

 SOLUTION for Angular 404 Not Found error on refresh or redirect  Sometimes when we create a production version of angular app , We can face a issue of 404 not found Why 404 not found error showing on redirection on other page or on refresh ? Angular is SPA(single page application) so it use html5 history for redirection and we refresh or redirect , its not able to find that routes thats why it shows an error of not found   Solution We can solve this issue by multiple ways but one of the easiest way is using htaccess. So if you are using Apache server then you can create a file on your root folder and put below content in it RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^ index.html [L] Now save this file and try to refresh or navigate to another page, It will work.

Cakephp rewrite .htaccess rule to allow access of a main root folder

Cakephp rewrite .htaccess rule to allow access of a main root folder This solution will work with any framework so you can use it in any php frameworks In CakePHP sometime  we want to allow a folder access that exists on the root access but CakePHP do not allow us to any main root file directly so here is the simple solution of this issue Go to your directory that you want to allow public access Now create a new .htaccess file in it. For example my project folder name is cakeapp and "foldername" is our folder name that we want to allow access,  then my new .htaccesss file location will be cakeapp/foldername/.htaccess Now paste below code in it <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f </IfModule> Thats it , now go to browser and try to access it directly. :) Related Links allow access to a specific folder in root directory .htaccess prevent access of root folder except one.