Question: how to configure .htaccess in spring boot?
angularjs provides html5Mode, which makes your app use pushstate-based URL instead of hashtags. However this requires server side support, since the generated urls need to be rendered properly as well.
If you're running your angular app on an apache server you can easily add this rule in an .htaccess file.
# Apache .htaccess
# angularjs pushstate (history) support:
# See http://www.josscrowcroft.com/2012/code/htaccess-for-html5-history-pushstate-url-routing/
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteCond %{REQUEST_URI} !.*\.(cssĀ¦js|html|png) #Add extra extensions needed.
RewriteRule (.*) index.html [L]
</ifModule>
Related
I have Laravel 6 running well on my localhost but when I deploy on domainsite.com, it only shows the main page but the rest of links shows 404 page not found. I am using CentOS 7, aaPanel running nginx server. PHP 7.4 MySQL.
I have this config so far.
URL Rewrite:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
fileinfo installed
I have removed in Disabled Functions(putenv and symlink) but still I get the error.
Anyone have tried this? Thank you!
I have a Laravel project where I also run APIs for an APP.
After adding rewrite rules in .htaccess file my APIs of an APP stopped working.
#Redirect to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I am trying to deploy a Laravel 7 application to Elastic BeanStalk but having some problem with the routing.
I have followed the tutorial from the video below and upload the zip archive with all my local files.
I have also fixed the permission issue after having set the root to /public.
Currently, the only page visible is the homepage whereas al the other pages like /login, /register and the other show me a 404
here is the log of the from eb:
2020/05/01 14:19:30 [error] 4091#0: *4 open() "/var/www/html/public/login" failed (2: No such file or directory), client: 82.4.194.3, server: , request: "GET /login HTTP/1.1"
https://www.youtube.com/watch?v=ISVaMijczKc
I suppose you are using Beanstalk PHP platform with Linux in version 2; this version uses Nginx (whereas the previous version uses Apache).
You can see more details in the official documentation: https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP
In that case, you have to configure Nginx for redirection as described in the Laravel documentation: https://laravel.com/docs/7.x/deployment#nginx
Just create the file .platform/nginx/conf.d/elasticbeanstalk/laravel.conf (at the root of your project):
location / {
try_files $uri $uri/ /index.php?$query_string;
}
Feel free to add other configuration for your need.
You will find more details about extending the platform here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
After several attempts, I have it up and running. I had deleted the application and used EB CLI to create it again.
I created an environment config and placed it in .ebextentions and I added AllowOverride All
Here is the content of my 01-environment.config
option_settings:
aws:elasticbeanstalk:container:php:phpini:
document_root: /public
composer_options: --no-dev
aws:elasticbeanstalk:application:environment:
APP_ENV: production
APP_KEY: base64:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
and my .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
AllowOverride All
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I am using shared hosting.
I have installed my laravel application and i am using unisharp Laravel File Manager.
With the manager, I uploaded file "happy.jpg". it produced url "http://unpluggedworldofmine.com/storage/photos/1/happy.jpg" but i cannot access to the file.
instead, when i use
"http://unpluggedworldofmine.com//storage/app/public/photos/1/happy.jpg", i can see that i has been uploaded properly.
it looks like there is problem with .htaccess
RewriteEngine on
RewriteRule ^/?$ /public/ [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*) /public/$1 [L]
AS i am using shared hosting, i cannot change configuration in httd or others.
i used
php artisan storage:link
to set up link.
can anyone help me with this?
Thanks
I've just setup an AMP server on OSX 10.9 and have a bizzare problem which is not present on my live hosting server or my old WAMP server.
I want to redirect any URL that doesn't directly map to a file on the server to index.php. I'm using the following .htaccess code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# prevent loop
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.*)$ /index.php?/$1 [L]
when I try http://example.com/example there is no problem, but when I introduce another slash, for example, http://example.com/example/
I get the a 404 error The requested URL /example.html/ was not found on this server.
Server version: Apache/2.2.26 (Unix)
Looks like your problem is related to enabling of MultiViews here. Turn it off by using this line on top of your .htaccess:
Options -MultiViews
Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.