Laravel on Plesk Routing Issue - php

I can't access my routes when I uploaded my site on Plesk. I get 404 error
I am using Laravel Version 4.2
I made the default directory to httpdocs/public/
Here's my .htaccess file in public folder.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Please help.

Related

Can not run a Laravel 5 App with in a Laravel App - Not Found Http Exception

I'm new to Laravel and trying to figure out this situation. I have a Laravel 5 app. And now I have to run same application with some changes into its Sub Directory. So what I've done is, I've duplicated the application into v2 Sub Directory as follows:
.htacceess at both roots of Main Application and v2 Application:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /
# Send requests to public directory...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ public/index.php [L]
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
</IfModule>
<IfModule security2_module>
SecRuleRemoveByTag unoeuro
</IfModule>
.htacceess at v2 Application public folder:
<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]
RewriteBase /v2/
# 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>
And this is the result when I access v2 Application via http://localhost:8000/v2:
I have tried so many ways but failed. Any help will be really appreciated! Thanks.

Rewriting URL from htaccess is doing wrong

I have a Laravel project and I have defined routes like:
Route::get('/', 'WebController#index');
Route::get('/user/signin', 'WebUserController#userLogin');
Route::get('/user/signup', 'WebUserController#userRegister');
Route::post('/user/save', 'WebUserController#userSave');
And the absolute routes of my project are:
localhost/project/ (it's working ok)
localhost/project/user/signin wasn't working ok.
Then, I added a .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]
</IfModule>
And the routes for signin and signup are working good, except when I'm trying to use user/save from signin is redirecting to:
localhot/user/save
What is wrong with my .htaccess fie?

How to remove public/index.php from url in laravel 5?

I am using laravel 5 and having one problem when i upload my project on rackspace it is showing public/index.php in the url. Without this my project is not working.
Please help me .
Htacesss of my public is this :-
<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>
With regards
Harpartapsingh
You do this by making the /path/to/laravel/public folder itself your webroot in Apache/nginx instead of /path/to/laravel. With that, and the standard .htaccess in the public folder, you should be able to access your routes without the public or index.php URL segments.
copy your .htaccess file from your public folder and paste in your root directory
with this code inside .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]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Show requests from root folder to subfolder

I'm using Laravel for my website, but i'm encountering a problem.
My website does not have any public_html or htdocs folder, but the root itself it is already public. Because of this i'm obliged to put all the Laravel files to the root folder.
To who doesn't know, when using Laravel the public folder is generally the subfolder public, therefore right now if I want to access my Laravel web applicaton I have to navigate to http://www.mywebsite.com/public.
I need to edit the .htaccess in order to show from http://www.mywebsite.com/ the subfolder public files and deny any access to the root files.
So http://www.mywebsite.com/public/index.php should be http://www.mywebsite.com/index.php, http://www.mywebsite.com/public/images/logo.png should be http://www.mywebsite.com/images/logo.png and so on.
Now I'm wondering, is it even possible?
Laravel .htaccess original 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've been successful to solve this myself by editing the original .htaccess to:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond public/%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ public/$1 [L,R=301]
# Handle Front Controller...
RewriteCond public/%{REQUEST_FILENAME} !-d
RewriteCond public/%{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
</IfModule>

Laravel: Setup .htaccess of Folder outside of Laravel App

I have Laravel installed in /var/www/html
I have a PHP script installed in /var/www/html/i/
The htaccess of /var/www/html/ is
<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]
The htaccess of /var/www/html/i/ is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.+)$ /?variable=$1
</IfModule>
Trouble is whenever I go to
/i/somevariable
I get a 404 error from my laravel app.
Make a .htaccess file in your root folder with this content:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^([A-Za-z0-9-]+)/i/?$ index.php/i/?s=$1 [NC,L]
This should work fine.
if you are using apache
read mod_rewrite
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
dont just turn on,
use rewrite rule

Categories