Yii Framework Forum: wrong route when URL contains trailing slash - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

wrong route when URL contains trailing slash Rate Topic: -----

#1 User is offline   phantomlord 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 15-October 17

Posted 18 October 2017 - 08:30 AM

I have to support one old project which uses Yii1. I get very strange behavior. Pretty URL is configured.

When URL doen't have a trailing slash (e.g. /about or /blog/post/5) everything goes OK (the route is correct and the correct page is displayed). But the same URLs with trailing slash (/about/ or /blog/post/5/) make a wrong route. Disregarding of url I always get the route 'main/index' and index page is displayed (not redirected to, but displayed at all URLs with trailing slash).

Any ideas?
0

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,824
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 18 October 2017 - 09:49 AM

Which Yii version?

What's in the urlManager config section?
Don't forget to read The Definitive Guide to Yii (1.1 en) (1.1 sv) (2.0 en) | The class reference (1.1) (2.0) has the details
0

#3 User is offline   phantomlord 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 15-October 17

Posted 19 October 2017 - 01:12 AM

Version is 1.1.19.

'urlManager' => [
	'cacheID'          => null,
	'class'            => 'UrlManager',
	'urlFormat'        => 'path',
	'caseSensitive'    => true,
	'matchValue'       => true,
	'showScriptName'   => false,
	'urlSuffix'        => '/',
	'useStrictParsing' => true
	]


When I remove urlSuffix it doesn't change the behavior.


Also useStrictParsing doesn't work. I can write any "bla-bla-bla" as URL and it also shows me the index page.
0

#4 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,824
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 19 October 2017 - 06:20 AM

Obviously you have a customized UrlManager (instead of default CUrlManager).
Perhaps something related to that one.

(my old pre-2012 simple lab projects need the url rules. I tried but didn't get any problem with a trailing '/'.)
Don't forget to read The Definitive Guide to Yii (1.1 en) (1.1 sv) (2.0 en) | The class reference (1.1) (2.0) has the details
0

#5 User is offline   phantomlord 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 15-October 17

Posted 19 October 2017 - 10:25 AM

Thank you for replies!
It seems to be a problem with environment. The same code works well on one VPS, and produces the described problems on another. This is even more strange. PHP version is the same, nginx config the same.

Maybe you are aware of any incompatibilities or denendencies?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users