I'm making a web game. The backend is Lumen and the frontend is a single page application. I want to make a use of JavaScript History API, so all URIs (except for actual file or directory paths) should point to the same backend script. I know how to do it on Apache, but my local server is Laravel Homestead, which is nginx.
If it was Apache, I would put this to .htaccess:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Is there any built-in rewrite functionality in Laravel Homestead? If not, how can I achieve the same effect on nginx?
Related
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 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 installed cs cart on new server and also enabled the API user access. But the api is giving back 404 not found error. Not sure what is needed in here.
Can anyone please help!!
please try yoursite.com/api.php?_d=products (e.g. in browser)
if it works, make sure that .htaccess root file (for apache servers) has lines:
RewriteCond %{REQUEST_URI} ^api/(.*)$ [or]
RewriteCond %{REQUEST_URI} .*/api/(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .*api/(.*)$ api.php?_d=$1 [L,QSA]
it might mean issue with mod_rewrite which is not configured or configured incorrectly on the server
p.s. if the server is on nginx, analogue configuration is needed
Enable API for an administrator user
Folow documentation
https://docs.cs-cart.com/4.9.x/developer_guide/api/index.html
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>
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.