I have a Laravel website and a WordPress blog installed on a shared hosting and trying to implement the following:

Visiting https://www.example.com should forward the request to a subdirectory public, without rewriting the url. This I have achieved by

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

What I want to prevent is the user manually opening https://www.example.com/public. This should redirect the user to https://www.example.com.

The other issue that I have is that my blog is installed in public/blog folder. I want to be able to load the blog by visiting https://www.example.com/blog. At the moment this is possible, but only if I type https://www.example.com/blog/ (with a trailing slash), otherwise it opens https://www.example.com/public/blog.

Please advise me how to define the .htaccess file and if the folders structure is fine. Another idea that I had is to take the blog folder out of the public folder, which is part of Laravel and just have two separate folder in the root www folder.

Read more here: Redirect Laravel installation and blog using .htaccess


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: