jom Posted September 30, 2016 Share Posted September 30, 2016 Hi everyone Since this is my first post: thanks for this beautiful CMS/CMF und thanks for this high quality forum. I'm struggling with following: A client imports a list of books from a csv file (using module ImportPagesCSV). The page name gets autogenerated by the core (it takes the value from the title field). If the title is very long, the page name gets truncated to 128 characters. This works fine, as long as I don't use urlSegments. Using them, PW returns a 404: http://domain.tld/...long-title-hier-128-characters.../ : workshttp://domain.tld/...long-title-hier-128-characters.../urlSegment1/urlSegment2/ : does not work It works fine, when I shorten the page name manually to e.g. 100 characters. This is not a good practice, since the client imports the list every couple of weeks. Is this a correct behaviour? Should I limit the page name via API to 100 characters? If yes, would I do this in the ImportPagesCSV-Module or better implement as a hook? Thanks in advance for some light in the dark! Oliver Link to comment Share on other sites More sharing options...
Sergio Posted September 30, 2016 Share Posted September 30, 2016 Quick question: are URL segments allowed in the template settings? Link to comment Share on other sites More sharing options...
jom Posted October 1, 2016 Author Share Posted October 1, 2016 Yes, urlSegments are enabled, everything works fine with shorter urls. Link to comment Share on other sites More sharing options...
BitPoet Posted October 2, 2016 Share Posted October 2, 2016 I've run some local tests, and I can't reproduce the problem. Can you make sure there isn't any external software (firewall/proxy, browser addons etc.) interfering with the request, i.e. compare the request URI sent by the browser and the entries in the web server rewrite and access logs? The whole URI should be passed to index.php in the "it" GET parameter. If it is, I'd also take a look at third party modules as a possible culprit. Link to comment Share on other sites More sharing options...
jom Posted October 3, 2016 Author Share Posted October 3, 2016 Thanks for your input, BitPoet. I've tried with several computers and browsers on different locations. No difference. The request URI matches to the logged URI. Not sure about the "it" parameter: I inserted echo wire('input')->get('it'); into index.php. No result. Did I get you wrong? There weren't any third party modules present when the problem occured the first time (apart of ImportPagesCS). Where would you set the limit for the page name? Add a module to the page->save hook? Link to comment Share on other sites More sharing options...
BitPoet Posted October 3, 2016 Share Posted October 3, 2016 What I meant was comparing regular web server logs. Assuming you're using apache, you can enable logging for mod_rewrite and see if requests to /some/path are correctly re-written to /index.php?it=/some/path. If you can't see anything wrong there, I'm at a loss too. A good place to hook would probably be Pages::saveReady. 2 Link to comment Share on other sites More sharing options...
jom Posted October 5, 2016 Author Share Posted October 5, 2016 I'm on a shared hosting environment, not sure if I can get the mod_rewrite logs. I asked the hoster for it. In the meantime I implemented a workaround. Since the urlSegments are not vital, I skip them, if a 404 is based on a too long page name. For this I wrote a function which hookes into pageNotFound: public function init() { $this->addHookBefore('ProcessPageView::pageNotFound', $this, 'displayItem'); } public function displayItem($event){ // redirects to url without segments, if there is a long page name involved $pageWithLongTitle = ''; $file = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); $urlParts = explode('/', $file); $urlWithoutSegments=''; foreach($urlParts as $urlPart){ if($urlPart){ $urlWithoutSegments .= $urlPart.'/'; if (strlen($urlPart) > 110){ $pageWithLongTitle = $urlPart; break; } } } // if there is a long title in url and a page with this title exists, then redirect if($pageWithLongTitle && wire('pages')->get("title=$pageWithLongTitle")){ wire('session')->redirect('/'.$urlWithoutSegments); } } Thanks for the help! Link to comment Share on other sites More sharing options...
jom Posted October 12, 2016 Author Share Posted October 12, 2016 In the meantime I got the mod_rewrite error log. Indeed, there is an error regarding my topic: [Wed Oct 05 18:42:00.073367 2016] [core:error] [pid 85277:tid 34669321216] (63)File name too long: [client 12.34.56.78:54004] AH00127: Cannot map GET [here follows the repeated path] It seems the paths gets in a loop - it is about 10 times repeated in one string. Now I'm lost - where to go from here? By the way in the first repetition the path is including the urlSegments, the following repetitions are without. Link to comment Share on other sites More sharing options...
jom Posted March 17, 2020 Author Share Posted March 17, 2020 just for documentation purposes: looks like Ryan added an option in $config: $config->maxUrlSegmentLength = 128; see also: 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now