Mobile app version of vmapp.org
Login or Join
Angie530

: How to issue .htaccess for Laravel? I have just launched a Laravel 5.3 project on a live server and all is going well except one. But my issue is, my websites are running on all 3 different

@Angie530

Posted in: #Apache2 #Htaccess

I have just launched a Laravel 5.3 project on a live server and all is going well except one.

But my issue is, my websites are running on all 3 different URLs:


example.com
example.com/public/index.php
example.com/<any-word>/index.php


My .htaccess is: (This file is in the root folder)

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ %1%{REQUEST_URI} [R=301,QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ / [L,R=301]

RewriteRule ^(.*)$ public/index.php [L]
</IfModule>


But I just want to see my website with example.com URL only.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Angie530

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

You would need to issue an external redirect before your existing directives. For example, immediately after the RewriteEngine directive, try something like:

RewriteCond %{REDIRECT_STATUS} ^$
RewriteRule ^[^/]+/index.php(.*) / [R=301,L]


Make sure you clear your browser cache when testing.

The RewriteCond directive, checking against REDIRECT_STATUS, prevents a redirect loop after the internal rewrite at the end.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme