0

I researched about this problem and found many solutions, but could not find a solution to the problem which arise after editing .htaccess file. Here is my problem. I followed this solution for removing 'public' from URL of my laravel website and it works fine. However, when I open my website with 'public' at the end of base URL, it also opens up the same page. As far as I know, it's a bad thing from the SEO's point of view. I want my site to be opened only with the base URL and not with 'public' at the end of the base URL. My website is on shared hosting. How can I achieve that?

This is how my .htaccess file looks right now -

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • 1
    Welcome to SO Ashish, good that you have shown your efforts, keep it up. Could you please do mention from which url to which url you want to redirect/rewrite for better understanding of question please. – RavinderSingh13 Dec 02 '20 at 12:41
  • Have a look at https://stackoverflow.com/questions/35461322/upload-laravel-5-to-server-subfolder/35474800#35474800. Default .htaccess that comes with Laravel need not be changed – Donkarnash Dec 02 '20 at 12:56
  • @RavinderSingh13 I wanted to open my site only with base url like 'mysite.com' and not like 'mysite.com/public'. I was able to fix it with the help of Donkamash's answer. Thanks Donakamash for help. However I did not create a separate folder for containing the laravel root files. I simply placed the root files one level above the 'public_html' folder and now my site does not open with 'public' at the end of URL. – Ashish Roy Dec 02 '20 at 21:10

0 Answers0