Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

YuMp's avatar
Level 2

Urls indexed in Google with index.php

Hello everyone, I'm facing a problem with google's WebMasterConsole, some posts are indexed as follows url.com/index.php/p/57 when the person enters, the site doesn't change anything but the adsense ads are not displayed, someone passed so is it google search problem or is it some htaccess rule? laravel 9 project. Thanks in advance.

My .htaccess file

Options -MultiViews -Indexes
RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
0 likes
3 replies
bobbybouwmann's avatar

You can add a rewrite rule to force redirect /index.php to /

Something like this should work, make sure you test it properly!

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php[^/] /? [L,R=302,NC,NE]

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php(?:/(.*))?$ /? [L,R=302,NC,NE]

Source: https://stackoverflow.com/questions/25105872/remove-redirect-index-php-from-url-to-prevent-duplicate-urls

1 like
YuMp's avatar
Level 2

@bobbybouwmann Hi, thanks for your answer, one problem i m try implements in localhost for test, acessing url.com/index.php not remove /index.php.

trying in localhost for implement in production, any idea to solve this?

bobbybouwmann's avatar

@YuMp Simply answer, don't use localhost/index.php. Use a proper setup and make your setup use website.com/ for local testing.

Please or to participate in this conversation.