i have an /admin folder and i cant delete becaus there are old files linked externaly and i need to use the /admin route.
When i use the /admin route i have a loop, if i rename the admin folder, it works, but i cant do that permanently.
If i use another route like /admin/anything, it works.
How can i have the folder and the route work together.
Here are my routes:
Route::post('admin/login/valida', ['before' => 'csrf', 'uses' => 'LoginController#getValidar']);
Route::get('admin/login', 'AdminController#Login');
Route::get('admin/asociarmenuarchivo', 'AdminController#Asociarmenuarchivo');
Route::get('admin/disenosnuevos', 'AdminController#disenosNuevos');
Route::get('admin/disenosnuevooantiguo', 'AdminController#switchDisenos');
Route::get('/admin', 'AdminController#getIndex');
The last one is the only route that doesnt work.
Here is my .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
# RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/cm/.*
#RewriteCond %{REQUEST_URI} !/admin/.*
RewriteCond %{REQUEST_URI} !/correo/.*
RewriteRule !^/?admin index.php [L,QSA]
RewriteRule ^ index.php [L]
ErrorDocument 401 "Unauthorised"
</IfModule>
The problem was the slash rewrite, the solution was:
RewriteCond %{REQUEST_URI} !/admin/.*
RewriteRule ^(.*)/$ /$1 [L,R=301]
Related
If I go to website.com then my website works correctly.
If I go to www.website.com then I get redirected to www.website.com/public/public which 404s.
If I then go to www.website.com/public it works correctly (but I don't want the added /public)
I want it so that both website.com and www.website.com use the same page.
without any publics added/needed in the URL.
Here is the .htaccess which is in the root laravel folder (inside public_html)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ public/$1 [L]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]
#RewriteBase /laravel/
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
AddType x-httpd-php72 .php
The reason I'm using the rewrite rules are so that I can access assets without using /public e.g /public/css/app.css is /css/app.css
I fixed it. The issue was my env had http://website.com rather than http://www.website.com.
I am looking at a stock laravel 5.8 project and I am trying to understand how does Laravel redirect all the requests from the / to the /public folder.
There is no index.php file in the root and no .htaccess to redirect traffic to public?
laravel 5.8 i use the following
root .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
public/.htaccess
<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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
i have a folder that name is admin in root of laravel project.and there is js, css, images and fonts in that folder.Now how can i deny other's to access that folder in laravel?
i solve it with this code in htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^admin(.*)/$ /$1 [L,R=301] //this line is for admin folder access limitation
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Even /home is 404. I just start learning laravel, I don't know if I did something wrong.
After reinstall composer and created a new project the problem still
exist.
Xampp is running.
Here is the .htaccess in public:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
have you added Route::get(/home, HomeController#index); to your routes file?
I'm using Laravel 5. My site has url:
"mysite/subfolder/"
But now urls are not working. They redirect to "mysite". How to fix that?
My routes are:
Route::get('/page/{page}/', 'HomeController#index')->where('page', '[0-9]+');
Route::get('/', 'HomeController#index');
My link is proper:
"mysite/subfolder/public/page/7/"
But when I click it, it redirects me to "mysite".
How to add whole path to base url?
My .htacess file is:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
#Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I assume you are experiencing this after you moved your website to a host or something?
Look at this post on how to set this up:
https://driesvints.com/blog/laravel-4-on-a-shared-host