Hi,
So I'm migrating a website from WordPress to Laravel. I'm making the same website and I need to be sure the URLs stay the same to avoid SEO problems. In the WordPress website all URLs end with a slash and in Laravel, every existing route URL can be utilized both with and without a trailing slash, and you'll receive a HTTP 200 response in either case. However, for search engine optimization purposes, this is not ideal, as the URLs are considered different and therefore result in duplicated content.
What I've done:
I installed a package called illuminatech/url-trailing-slash. What this package does is add a slash at the end of the URL. So for example, a route www.domain.com/contact will redirect to www.domain.com/contact/
I followed all the instructions and everything is working fine, now the routes are being redirected with the requested route with a slash at the end.
What I need to fix:
After testing, I realized that the route now can be accessed via www.domain.com/contact/ (which is correct and how it should be) and www.domain.com/responsive/public/contact/
My Laravel project is located in public_html/responsive
My .htaccess file inside public folder looks like this:
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Remove public URL from the path
RewriteCond %{REQUEST_URI} !^/responsive/public/
RewriteRule ^(.*)$ /responsive/public/ [L,QSA]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I don't know if .htaccess file located in public_html has any effect on this matter but I'll add it here anyway:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^laravel.domain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.laravel.domain.com$
RewriteCond %{REQUEST_URI} !responsive/public/
RewriteRule (.*) /responsive/public/ [L]
AddHandler application/x-httpd-php81 .php .php5 .php4 .php3
I hope my explanation was good enough and wish somebody can help me out with this.
Very much appreciated!