Issue with the Laravel Public URL
asked 16 hours ago by @qa-klqk7cy7w2rvrct50aim 0 rep · 59 views
RewriteEngine On
# Block direct access to /public/* from the browser
RewriteCond %{THE_REQUEST} \s/+public[/\s?] [NC]
RewriteRule ^ - [F,L]
# Redirect everything else internally to /public folder
RewriteCond %{REQUEST_URI} !^/public
RewriteRule ^(.*)$ public/$1 [L,QSA]
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(js|css|png|jpg|jpeg|gif|webp|svg|woff|woff2|ttf)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
</IfModule>
This is my .htaccess file. This is located in the root directory of the laravel project here and my index.php file and one .htaccess file exists in the public folder means i have two .htaccess file one in root directory and one in public folder.
The issue is when I am opening the URL https://example.com and one duplicate URL is there https://example.com/public I want if the user goes the duplicate URL with the pubic there should show 404 or 403 and only https://example.com should be work not the URL with the public.