Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7847343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:51:53+00:00 2026-06-02T17:51:53+00:00

I create a URL like this: $app->createAbsoluteUrl(‘/’, array( ‘param1’ => ‘val1’, ‘param2’ => ‘var2’,

  • 0

I create a URL like this:

$app->createAbsoluteUrl('/', array(
     'param1' => 'val1',
     'param2' => 'var2',
);

The generated URL is:

http://mysite.com/param1/var1/param2/var2

But I expect a url like this:

http://mysite.com/?param1=var1&param2=var2

In function manual it says:

$params array additional GET parameters (name=>value). Both the name and value will be URL-encoded.

But it doesn’t seem to work like that. How I can generate the expected URL? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:51:54+00:00Added an answer on June 2, 2026 at 5:51 pm

    You need to specify that the urlManager application component should use the “get” format for the URLs it generates; the default is to use the “path” format. The Yii guide explains how to do it inside your application configuration:

    array(
        ......
        'components'=>array(
            ......
            'urlManager'=>array(
                'urlFormat'=>'get',
            ),
        ),
    );
    

    Update: So your urlFormat is “path” and that’s by design… what about alternatives?

    If you don’t mind extending CWebApplication and using your own derived class in its place then you have several options such as:

    1. Define your own createUrlEx method based on the original createUrl. It could look like this:

      public function createUrlEx($format,$route,$params=array(),$ampersand='&')
      {
          $oldFormat = $this->getUrlManager()->getUrlFormat();
          $this->getUrlManager()->setUrlFormat($format);
          $url = $this->getUrlManager()->createUrl($route,$params,$ampersand);
          $this->getUrlManager()->setUrlFormat($oldFormat);
          return $url;
      }
      
    2. Override registerCoreComponents so that you can have a second url manager:

      protected function registerCoreComponents()
      {
          parent::registerCoreComponents();
      
          $components=array(
              'specialUrlManager'=>array(
                  'class'=>'CUrlManager',
                  'urlFormat'=>'get',
              ),
          );
      
          $this->setComponents($components);
      }
      

      You can now call Yii::app()->specialUrlManager->createUrl(...) anytime.

    You can also approach the problem in other ways:

    1. Extend CUrlManager and expose a method that allows you to select the flavor of url to create on the spot.

    2. If you only need “get” urls in one or two places, you can always create a new CUrlManager object, configure it on the spot, call createUrl and then discard it. You could also hide this ugliness behind a free function. Essentially this (admittedly not recommended) approach is a low-tech version of the first workaround given that has the advantage that you don’t need to extend CWebApplication.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use this method to create user-friendly URL. Because my site is
YouTube has URL's like these: http://www.youtube.com/watch?v=zKqeCtjFGFc When I create a PHP page mine would
I want a macro that I can use like this: CREATE_URL(@{SOME-TOKEN}/some/url/path); The macro should
I would like to create a single URL that returns one image when loaded
I am using Google Checkout and I could like to create an absolute URL
I'd like to create a table: CREATE TABLE sfc.OpenId ( Url VARCHAR(255) PRIMARY KEY,
I want to create URL re-write rules for following URL in htaccess. http://example.com/vedios/category/fun/ ->
I'm using django templates to create an e-mail. I do something like this: msg_html
In a standard Rails controller, I'd create a record like this: @user = User.new(params[:user])
I have a web app of which I would like to create a mobile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.