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.
Related
I have a problem with .htaccess configuration for multiple Laravel projects on my Apache webserver. One project in the root folder and one project in a subfolder
File structure (/www)
/ <-- Laravel application #1
/anotherProject <-- Laravel application #2
When I'm visiting www.example.com/anotherProject then I get a 404 error (and www.example.com is working. The following .htaccess is activate in /public/ (for Laravel application #1).
/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]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
It feels like I need to change something in the .htaccess file of the project in the root folder. Has someone a suggestion to try?
I've a domain, like www.example.com
The main site is on FTP space visible as /example.com
I installed (copy/pasted, sigh... :( ) my Laravel app under /example.com/laravel_app.
I am able to open the laravel app, and it's fully working, if I access using full url http://www.example.com/laravel_app/public/index.php.
The problem is that, obviously, I'd like to access it using only the path http://www.example.com/laravel_app.
In the root of laravel_app, I tried to paste this .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
While in the /example.com/laravel_app/public i'm using this `.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /laravel_app/
# 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>
So my question is NOT related the .htaccess of app's public folder, but the .htaccess for app's root folder.
How can I succesfully serve
http://www.example.com/laravel_app/public/index.php
accessing
http://www.example.com/laravel_app
?
Actually I got Laravel returning a 404
I tried this variant (seen I some question very similar to this one)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php/$1 [L]
</IfModule>
But with this I got apache returning a forbidden
I'm assuming you have installed your application on shared hosting and ssince it's running Apache this solution should work.
Revert your .htaccess back to its original/what was deployed with laravel.
Ideally you shouldn't have your project uploaded in public_html as it exposes all the files to the web.
Move all your project files except public to a directory below public_html.
Eg.
/home/<username>
[laravel] <-- Make this directory
[public_ftp]
[public_html]
[ssl]
etc..
Then in your public_html move the files inside your public folder to the directory you want to serve your files (address you want to go to to use your app).
/home/<username>/public_html/laravel-app
[public_html]
[laravel-app]
-index.html
-robots.php
-.htaccess
-[css]
-[js]
-[svg]
etc..
Now edit your index.html file in the laravel-app folder and change both:
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
..to reflect the path where you moved yoru project folder.
require __DIR__.'/../../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
Essentially in this context ../ means back one folder, so the aim is to take it back to where it will find the laravel/vendor/ folder, vice-versa.
Realistically that should sort your issue out and make for a more secure application as your .env and composer, etc. files will not be publically available without messing with your .htaccess.
Oh, also here is the default .htaccess code which should be under your public folder <project>/public:
<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 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.
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.
I'm new to the Laravel framework. I am considering learning it and using it for a personal project, but as I am reading through the documentation I see that the web server document root would need to be set to the project folder.
Is it possible to integrate a laravel project with an existing webiste built with PHP and apache? For example, if I have a wordpresss install and wasn't using a framework but wanted tp create a subsite, I could just add more html and php files into a folder somewhere on the existing site or use a different vhost. Not sure if integrating would be so easy with Laravel,though.
Yes, it's possible. The solution I mentioned here should work for you.
To make it work you should modify both Laravel and Wordpress .htaccess files.
Laravel .htaccess example:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
#Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/blog/ # <=== NEW LINE!!!!
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Wordpress .htaccess example:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/ # <==== CHANGED LINE!!
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L] # <==== CHANGED LINE!!!
</IfModule>