Laravel htaccess trouble - php

I have my index.php file one directory above framework folder.
So, I have two versions of htaccess file each with its own troubles:
The Laravel friendly htaccess:
Works perfectly for Laravel, but when my link is shared on Facebook, it becomes www.myqourse.com/www.mqourse.com/..../.../... etc.
# Use PHP56 Single php.ini as default
AddHandler application/x-httpd-php56s .php
<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>
The no issues version for Facebook and Twitter:
Doesn't load resources (.js or .css) but Facebook and Twitter can only get a clean link.
# Use PHP56 Single php.ini as default
AddHandler application/x-httpd-php56s .php
DirectoryIndex index.php
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteRule !^(public/|index\.php) [NC,F]
Any help?

I mistakenly forgot to remove pretender.io from Kernel.php as a global variable 6 months ago. I did it locally, but forgot to push to the server that one particular file :/

Related

Install WordPress inside Laravel public folder

I am trying to install WordPress into Laravel public folder. I have completed the installation, but when I am trying to access the same with URL getting WordPress home page without any design.
Please find the .htaccess files of Laravel
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
#Exclude url with quora
RewriteCond $1 !^(quora)
# 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>
WordPress .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /quora
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /quora/index.php [L]
</IfModule>
Dont put your wordpress folder inside laravel public's folder, it's a wrong way to do it and can cause problem.
I advise you instead to create 2 folders on the server root, one with laravel and one with wordpress.
Then to access to wordpress from laravel you have two choice,
use a subdomain (wordpress.exemple.com)
create an alias (exemple.com/wordpress)
I think what your looking for is the alias so
to create the alias, create a new apache conf but instead of using server property, use alias property
Alias /wordpress /var/www/wordpress/
<Directory "/var/www/wordpress/">
//here your directory conf
</Directory>
enable the conf in apache, restart the server and now, on laravel when you go to the route /wordpress you're on wordpress.

how to redirect to the public folder

When filling on hosting, I faced the problem that you can not select the start folder of the opening. When opening a link юhttps://my-domen/ this opens
to get to the site, enter /public
how to make sure that when you open the site, the public folder is immediately opened on the hosting so you can not configure it . Can I use htaccess or something else? If this helps then the laravel files are a clean project
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>
In your root folder use this .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
In the public folder use the new clean laravel .htaccess file

Configure Htaccess in Laravel to serve website

I have this folder structure for laravel app I uploaded it online to cpanel.
But if I access this laravel app in browser, I need to access it like this
http://venkasure.com/venkasure/public/
where as I was expecting it to be as http://venkasure.com
I am not sure whether it's because of .htaccess settings .
My .htaccess file in 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]
# 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>
I don't have much experience in configuring htaccess files, need help or do I need to add htaccess file in root.

laravel: remove folder directory in url shared hosting

I just recently deploy my Laravel app and I want to remove the folder directory. Example:
example.com/laravel/anotherfolder/home
I want to remove the laravel because that is the folder
I have tried searching on google but they don't work, here is my .htaccess
DirectoryIndex public/index.php
<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 ^laravel/(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>`
Depending on your shared host provider, you need go on your control panel and change the public directory to laravel/public.
Another solution would be to replace the current public folder by a symlink which links to laravel/public. You'll need an SSH access for this solution.

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>

Categories