Ionut Flavius Pogacian
Ionut Flavius Pogacian

Reputation: 4811

Yii2 url is to long so I receive a 403 code

Is there any setting for url limit in Yii 2?

Some of my urls are over 300 characters and I get a 403 Forbidden code;

http://website/servicii-de-proiectare-asistenta-tehnica-din-partea-proiectantului-pe-perioada-derularii-lucrarilor-si-executie-de-lucrari-pentru-proiectul-%E2%80%9Emodernizare-drumuri-comunale-dc----dc----si-dc---a-de-pe-raza-comunei-lunca-judetul-boto-ani%E2%80%9D-863506-switch.html

If I shorten the url, it works.

this is my urlmanager rule:

'<title:(.*)>-<id:([0-9]+)>-access-not-granted.html' => 'member/licitatii/access-not-granted',

Upvotes: 0

Views: 526

Answers (2)

Mihai P.
Mihai P.

Reputation: 9367

Why would that rule apply to your URL? From what I can see your URL will never trigger that rule.

I do not think there is a limit with the string of the URL in Yii2, try deleting some of the first part of the string to test this. try with an url like

http://website/proiectul-%E2%80%9Emodernizare-drumuri-comunale-dc----dc----si-dc---a-de-pe-raza-comunei-lunca-judetul-boto-ani%E2%80%9D-863506-switch.html

You might have problems because you have diacritics in the URL, try without them.

Upvotes: 0

Ares Draguna
Ares Draguna

Reputation: 1662

I tried to find some information regarding this issue and surprisingly enough, I didn't found a thing regarding URL length permitted.

However, I found a Yii way to solve your issue: Short URL Yii extension presented here - http://www.yiiframework.com/extension/google-url-shortener/

Also, please read this documentation that better explains how Yii treats URL routs: http://www.larryullman.com/2013/02/18/understanding-routes-in-the-yii-framework/

I know this does not solve your problem directly, but hope it gets you somewhere!

L.E: Here you have the bitly extension for Short URL's: http://www.yiiframework.com/extension/bitly-url-shortener/

Keep on coding,
Ares.

Upvotes: 1

Related Questions