Currently building a web application with Laravel but have a strange bug which I can't seem to find a solution to.
The url:
http://localhost/posts/acd572e873d22c29b4dbc20f18a3e4dd
Loads the page correctly however the url
http://localhost/checkouts/acd572e873d22c29b4dbc20f18a3e4dd/
redirects to
http://localhost/AppName/public/checkouts/acd572e873d22c29b4dbc20f18a3e4dd
Not a clue what I have changed or done to have this happen. My current .htaccess in my htdocs looks like this
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?localhost$
RewriteCond %{REQUEST_URI} !^/AppName/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /AppName/public/$1
RewriteCond %{HTTP_HOST} ^(www.)?localhost$
RewriteRule ^(/)?$ AppName/public/index.php [L]
Are they any files that I should check when it involves rerouting trailing slash? I would like it to reroute to just the non trailing slash version of the url
Apache/2.4.46 Laravel v8.0.3
As far as I remember Laravel 4.x was the last version having a "redirectIfTrailingSlash" function. Every next version had an initial .htaccess file containing the correct set of rules to redirect urls with trailing slash (but no dirs etc). I can see your .htaccess contains your own modifications which do this redirect. Replace your lines with the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301].
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.