Removing " ? " from links

Andere Lösungen
Post Reply
loukas25
Posts: 4
Joined: Sun 5. Jan 2025, 17:58

Removing " ? " from links

Post by loukas25 »

Good evening to the community.
I will upload a modification i made to the code to remove the ? from the links. Tested for 6 months with Apache server, without the slightest error.
If it is not allowed by the community rules, the administrator can delete the topic.

It only works with links in English

Steps:
In the root folder of our project, we open the "cmsimple" folder. Inside the folder, click and open the "functions.php" file.
Inside the file we look for: '<a href="./?'
In CMSipmle version 5.20 the code is in 5 places: Line 620, line 623 (X2), line 639 and line 1196.
After locating the points, what we do is remove the ? from the code. So the code on line 620 would look like this: return '<a href="./' . $u[0] . '">';
Only the symbol ? nothing else is deleted.

Extra Tip:
On line 639 there is the code: if ($f != $i) $t .= '<a href="./?'.amp().$i.'">';
This is where the sitemap link is set. You can also remove .amp(). which creates the & symbol in the link (/&sitemap). That is, after processing it should be like this:
if ($f != $i) $t .= '<a href="./'.$i.'">';

Finally, save your file, then navigate to the root folder and open the .htaccess file.
Add the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [QSA,L]
</IfModule>

Save the file and you're good to go.

Notes:
1. If you decide to follow the method on a live project, make a full backup first
2. Tested only on Apache 2.4 and php 7.4 - 8.4
3. I don't have any plugins installed, apart from the ones that come pre-installed in the official release of CMSimple 5.20
4. The creation of links in the core is not affected, the ? just disappears from the address bar. That is, if manually entering the ? in the link in the address bar, then the page works normally

When i find time i will make additional adjustments for anyone interested.
Good luck everyone.
Post Reply