i'm using laravel 5.0 on my server. i've just uploaded some images to my public/uploads folder.
But when i try to access them eg. /uploads/image.jpg, i'm receiving a 404 Not Found error.
Additionally my firefox browser says "Page is not redirecting properly" when i try to access just the "/upload/" folder(where i think it should be saying 403 forbidden or something).
how can i solve this problem? heres my .htaccess file :
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I think the problem for "The page isn't redirecting properly" is the follwoing line in your code:
RewriteRule ^(.*)/$ /$1 [L,R=301]
change it to this line :
RewriteRule ^/$(.*) /$1 [L,R=301]
the other code works fine for me .
Related
This is a VueJS application. I have a .htaccess file duplicated from any Laravel project like following;
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
</IfModule>
This is perfectly working what i want. But when I activated comment SSL Redirect rule lines redirects to SSL but routes not running index.html file, for example I have a /login route, /login request working without SSL redirect but if I add SSL redirect lines not working. Please show me when I'm wrong.
Okay, I was configure my Digitalocean server manually, I've forget to enable rewrite in SSL virtualhost. That's a solution :)
I am having error in the files.
This is my .htaccess file.
Redirecting error is mainly that it is showing a 404 error when I click login button then it redirects me to mydomain.com/login which shows me a 404 error as in the file ...
Options +FollowSymLinks -MultiViews
ErrorDocument 404 /warning/notfound
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^login$ login.php
</IfModule>
Options -Indexes
IndexIgnore *
Your question is not clear (to the least!) but here's the "translation" of your .htaccess file:
ErrorDocument 404 /warning/notfound if there's a 404 then redirect to /warning/notfound
RewriteCond %{REQUEST_FILENAME} !-d if the requested URL is not a directory then try to apply the next rule
RewriteRule ^(.*)/$ /$1 [L,R=301] Whatever is in the URL, if it ends with a / then remove it and stop URL rewriting rules (L = stop)
RewriteRule ^login$ login.php if the URL is login then redirect to login.php
Maybe the L is the source of your problem?
I hope I gave you enough clues to solve your problem!
Okay Now I have the answer actually there should be a slash here ..
RewriteRule ^login$ /login.php
This just solved my problem ...
I am New to Laravel5 framework as I got one task to install a laravel application into my local environment i.e into xampp.
I have copied all folders from the remote server and dumped in the htdocs inside a folder called project i.e(htdocs/project).
the folders i have copied has a public folder in which contains htaccess file and index.php.below is the code in the htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^ec\.
RewriteRule ^(.*)$ https://ec.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This htaccess file i have changed as below to redirect to index page
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
When I enter the url localhost/project/public it display's index page as
it has username and password field.
when i enter username and password and hit submit it
display's the below error and url will be redirected to localhost/login
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
Can Any one please help me how to redirect to correct location or some any extra settings to be made so that application should run fine.
Thanks in advance.
I'm working on a Laravel Lumen project and issue something strange. I created a restful API on some of the routes. If I call the API directly from my browser everything seems to work. However if I use an iPhone client application of a debugging interface an additional slash is added.
The API is currently located at:
http://.../public/index.php/api/fever?api&items
Whenever an iPhone application or debug tool is used the following location is requested:
http://.../public/index.php/api/fever/?api&items
This results in a 'page not found' error. Is is possible to use the apache htaccess rewrite rule to redirect all api/fever/? to api/fever? ??
The htaccess file has to be located in the public folder, which is located under a sub folder under the main website.
Thanks in advance
current htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
You can try this redirect rule at top of your site root .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{THE_REQUEST} !.*/api/fever/ [NC]
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
RewriteCond %{THE_REQUEST} \s/(.*api/fever/\S*)\s [NC]
RewriteRule ^ /%1 [L,R=301,NC]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
i'm working on a website at work and recenctly move it via svn to my localserver so i can work from home...
The setup went okay, no majors... but code ignighter sends 404 Not Found on pages along with the correct response...
For example i can load 'localhost/home' and it fires my controller and i get correct view, but CI also send 404 in headers for the page....!!
this also happens on my js files...
I can force it to send "200 OK", but doing this on every page seams silly..
Has anyone come accross this problem before...?
I'm using;
Code Ignighter: 2.1.0
Apache : 2.0.63
PHP: 5.1.6
this is my .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|js)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
Give the .htaccess example from the documentation a try:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
The following line could be responsible for your 404 response:
ErrorDocument 404 /index.php