Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
4df8a6e5
Commit
4df8a6e5
authored
Apr 18, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2899: added more details about canonical URLs to the guide
parent
7b44bc75
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
url.md
docs/guide/url.md
+21
-4
No files found.
docs/guide/url.md
View file @
4df8a6e5
...
...
@@ -87,10 +87,6 @@ echo Url::toRoute(['/date-time/fast-forward', 'id' => 105]);
Yii
::
setAlias
(
'@google'
,
'http://google.com/'
);
echo
Url
::
to
(
'@google'
);
// get canonical URL for the curent page
// /index.php?r=management/default/users
echo
Url
::
canonical
();
// get home URL
// /index.php?r=site/index
echo
Url
::
home
();
...
...
@@ -102,6 +98,27 @@ Url::previous(); // get previously saved URL
> **Tip**: In order to generate URL with a hashtag, for example `/index.php?r=site/page&id=100#title`, you need to
specify the parameter named
`#`
using
`Url::to(['post/read', 'id' => 100, '#' => 'title'])`
.
There's also
`Url::canonical()`
method that allows you to generate
[
canonical URL
](
https://en.wikipedia.org/wiki/Canonical_link_element
)
for the currently executing action.
The method ignores all action parameters except ones passed via action arguments:
```
php
namespace
app\controllers
;
use
yii\web\Controller
;
use
yii\helpers\Url
;
class
CanonicalController
extends
Controller
{
public
function
actionTest
(
$page
)
{
echo
Url
::
canonical
();
}
}
```
When accessed as
`/index.php?r=canonical/test&page=hello&number=42`
canonical URL will be
`/index.php?r=canonical/test&page=hello`
.
Customizing URLs
----------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment