Duplicate URLs Issue /public

rox94

Registered Member
Joined
Nov 6, 2024
Messages
70
Reaction score
34
Hi everyone,

I’m running a website built with Laravel in production, but I’m facing an issue with duplicate URLs. For example, my main URL is:

shoes.com/black
But the server also generates an additional URL with /public includeed:
shoes.com/public/black


The problem is that Google has indexed both versions (shoes.com/black and shoes.com/public/black), which is causing duplicate content issues. I understand that the root cause is likely related to server configuration, where /public shouldn’t be exposed. However, the site is still live, and I can’t make big changes to the server configuration just yet.

In the meantime, I’m considering using Google Search Console to manually deindex the /public URLs one by one. Would this be a reasonable temporary solution until I can properly configure the server and fix the issue?

If anyone has dealt with a similar situation, I’d appreciate your advice! Also, if you have recommendations on how to set up Laravel in production to avoid exposing /public, feel free to share.

Thanks in advance!
 
You can set the irrelevant webpage to noindex; do you want a hand with this?

The GSC path is a great idea too.
 
You can set the irrelevant webpage to noindex; do you want a hand with this?

The GSC path is a great idea too.
Sorry for the double post, I wouldn't do it to you, but I got curious and asked Claude...

That chat model is the best thing since sliced bread for help and advice with code.
 
what are you using for hosting ? CPanel ? if so then you probably need to configure the .htaccess file


Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^$ public/index.php [L]
    RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</IfModule>
 
Usually, you have to set canonical tags pointing to the main pages (without /public),
As well as blocking Google bots from crawling them (using robots.txt),
Or/and redirect the URLs to the main pages as pointed out by @Amar neche,

Since the URLs are already indexed, blocking them won't be ideal, as it will cause errors when bots try to recrawl,
Set canonical tags pointing to the main pages, or find a way to get rid of them (404s, better if you can set 410s),

Or just block them from getting crawled (robots.txt), but bots will have to recrawl each a couple of times to drop them out of the index,
They'll be seen as errors (blocked), not as a critical problem, neither will be ideal
 
Back
Top