Forum Moderators: Robert Charlton & goodroi

Google indexing pages with url parameters

         

coachm

4:20 pm on Mar 12, 2025 (gmt 0)

10+ Year Member Top Contributors Of The Month



Google has baiscally removed most/all my pages from a pure html site due to indexing pages with url parameters.

I've been researching solutions to solve the google indexing problem. What I'd really like to do is use some sort of script to generate canonical links and place them in the head sections of all pages. But I can'f find a script I feel I can trust.

I know there are several solutions, but looking for the easiest, which leaves out entering individual canonicals individually.

Pirilin

4:49 pm on Mar 12, 2025 (gmt 0)

Top Contributors Of The Month



You can use this php line to generate the canonical, but the first time, you will have to manually put it on all pages.

<link rel="canonical" href="<?php echo 'https://' . $_SERVER['HTTP_HOST'] . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); ?>">

coachm

5:19 pm on Mar 12, 2025 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you Pirilin. It's not a problem placing the code on each page since it's all templated. However, will this work on a pure html site, or does it require pages to be php?

NickMNS

6:11 pm on Mar 12, 2025 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes it would require php. But if it's all templated what framework / language / cms or other is used to populate the templates?

coachm

6:41 pm on Mar 12, 2025 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi Nick, and thanks. I'm using an older version of dreamweaver. I am testing Prilin's suggestion, and it appears to be working if I modify the .htaccess file to enable php processing on regular html files. Probably not the best way to treat a server, but it does solve the immediate problem.

NickMNS

6:57 pm on Mar 12, 2025 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm not sure how Dreamweaver works, but given that it is templated you should be able to include the link in the template and refer to the page's URL. Enabling php just for this seems like overkill and you could be opening security vulnerabilities if your not careful.

Pirilin

7:00 pm on Mar 12, 2025 (gmt 0)

Top Contributors Of The Month



Hello Coachm.
I'm glad it works, the ideal would be to convert all files to .php
but if the adjustment in .htaccess is working well, the important thing is that it works.

coachm

8:24 pm on Mar 13, 2025 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks, guys. It all works and all files now have canonicals. Hopefully that fixes the indexing problem. I know enabling php for html files incurs a server hit (so I'm told) but I'll do it this way until someone says STOP, or I find a better way.

lucy24

5:50 am on Mar 14, 2025 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the ideal would be to convert all files to .php
There's rarely, if ever, any reason to change a page's physical extension. If the server is happy to process one extension as if it were a different one (another common case is using SSIs without changing all pages to .shtml), let it.

Brett_Tabke

1:43 pm on Sep 26, 2025 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



> It all works and all files now have canonicals.
> Hopefully that fixes the indexing problem.

I can't imagine it did. If it has "url parameters" and google refused to index them, then something else is going on.
Did you add the 'url parameters' to the canonicals?


...domain.com/?foo=page1
vs
domain.com/page1

How'd you solve it?