Questions tagged [yii-url-manager]

The management of URL-addresses in web applications in the Yii framework.

The management of URL-addresses in web applications in the (Yii) framework. It involves two aspects:

  • The application needs to parse the query the user enters in the form of URL, for individual parameters;
  • The application must provide a method for forming address URL, with which it will work correctly.

In the Yii applications these problems are solved using a class CUrlManager.

The project API docs: http://www.yiiframework.com/doc/guide/1.1/en/topics.url

216 questions
66
votes
14 answers

Enable clean URL in Yii2

How can I enable clean urls in Yii2. I want to remove index.php and '?' from url parameters. Which section needs to be edited in Yii2 for that?
user7282
  • 5,106
  • 9
  • 41
  • 72
11
votes
3 answers

Passing multiple parameters in a hyperlink in yii2 with clean urls, Html::a() doesnt generate clean url

I am trying to generate a hyper link by the method mentioned in http://www.yiiframework.com/doc-2.0/guide-helper-html.html#hyperlinks like this Html::a('Register', ['story/create', array('id' =>39,'usr'=>'11')], ['class' =>…
user7282
  • 5,106
  • 9
  • 41
  • 72
10
votes
2 answers

YII 2 Get Site URL

My Application is deployed on localhost/upload. I am using following code to generate relative URL. Url::to('@web/my_controller/action'); // it returns /upload/my_controller/action But, I need full URL like this instead:…
Touqeer Shafi
  • 5,084
  • 3
  • 28
  • 45
10
votes
1 answer

Optional parameter on urlManager rules

I used the Yii::app()->request->getParam() so I can have a friendly url like /listings/amenities/1. I got 3 actions on my controller that get the parameter $property_id = Yii::app()->request->getParam('property_id'). The two actions amenities and…
Pelang
  • 421
  • 7
  • 19
6
votes
3 answers

SEO friendly url in Yii

I need a rule for http://example.com/post/view/id/1 url that will be displayed like this http://example.com/post/post_title. Instead of the id number i want to display the post name or title. My config looks like this: 'urlManager'=>array( …
Nogard
  • 172
  • 3
  • 12
6
votes
9 answers

Yii check if homepage

Is there a buildin method or property in Yii to check if page is homepage? I know i can use something like this: $controller = Yii::app()->getController(); $isHome = $controller->getAction()->getId() === 'index' ? true : false; Or put it in a…
user558134
  • 1,071
  • 6
  • 25
  • 38
5
votes
1 answer

How to override or edit code of vendor directory in yii2?

I need to do some changes in vendor/yiisoft/yii2/web/urlmanager.php for my url_alias to work! I need to know if I can change this file directly or is there any method to override this file?
sphinx
  • 717
  • 1
  • 7
  • 19
5
votes
3 answers

Setting unknown property: yii\web\UrlRule::GET

I have this error and I don't know to solved. I created an api endpoint with Yii2. A few days ago the endpoint was working but now it doesn't and raise this error: { name: "Unknown Property", message: "Setting unknown property: yii\web\UrlRule::GET…
Robert
  • 10,403
  • 14
  • 67
  • 117
5
votes
2 answers

How to deploy yii2 with a web root other than /web

I am working on a yii2 project, and would like to deploy it to an apache server where the entire website is expected to exist in the /public_html directory, and /public_html is the web root for that host. The issue is that yii2 expects the web root…
TMorgan
  • 655
  • 1
  • 7
  • 13
5
votes
4 answers

how to remove url (/web/index.php) yii 2 and set route with parameter with clean url?

first question: i already remove index.php, but i want remove /web also. this is my .htaccess RewriteEngine on # If a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise…
randawahyup
  • 389
  • 2
  • 5
  • 15
5
votes
2 answers

yii2 urlManager enablePrettyUrl not working

In Yii2, I cannot enable pretty url's. My config: 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, ], My .htaccess: RewriteEngine on # if a directory or a file exists, use it directly RewriteCond…
Ivo Renkema
  • 2,188
  • 1
  • 29
  • 40
4
votes
3 answers

Yii 2 Optional Parameter

Ok, I am transitioning an app from yii 1.1 to yii 2, unfortunately I cannot figure out how to use optional parameters within my url routes. Even when I set defaults in the urlmanager in config I can't state the second parameter without the first…
mezlad
  • 41
  • 1
  • 3
4
votes
3 answers

Yii2 Clean URLs & Action Parameters

I've enabled clean URLs on my Yii2 application, but I can't seem to get arguments to pass to the action. I expect this: localhost/app/web/a/b/c/d To map to the following: AController->actionB($c, $d) It's not happening. Here's my…
Tal V.
  • 671
  • 1
  • 6
  • 15
3
votes
1 answer

Yii2 url manager parameter before controller

I have a site where I want a different experience for each state, and need the url to be related to the city. So instead of mysite.com/site/login it would be mysite.com/utah/site/login mysite.com/colorado/site/login etc And this would apply to all…
Andrew Sparrow
  • 167
  • 2
  • 2
  • 12
3
votes
1 answer

Configuring urlManager Rules in Yii2

I'm new to using Yii2 and have been using the urlManager, I have the following code, it works fine however I think that this should be shorter. I have a couple rules as follows :- 'rules' => [ …
ahervin
  • 461
  • 2
  • 15
1
2 3
14 15