Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

canonical url problem REQUEST_URI

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
MajorONY
Smarty n00b


Joined: 03 Aug 2021
Posts: 1

PostPosted: Tue Aug 03, 2021 11:50 am    Post subject: canonical url problem REQUEST_URI Reply with quote

Hi,
I have this code:
Code:
{if $smarty.server.REQUEST_URI|strstr:"post"}
      <link rel="canonical" href="https://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" />   
      {/if}


To each url is attached: ?page_type=post

How can I make the url be:
https://domain.com/blog/post/1_test

I want to remove ?page_type=post
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Sep 08, 2021 1:36 pm    Post subject: Reply with quote

Create a wrapper function around https://packagist.org/packages/anrdaemon/net-url or any other similar URL handling library.

For Net\Url:

Code:
$query = $_GET;
unset($query['page_type']);
$url = AnrDaemon\Net\Url::fromHttp( [ 'query' => $query ] );
print $url;
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP