Slashes in article/category alias may cause rewrite problem

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
User avatar
adamderesz
Posts: 19
Joined: Sat 3. Oct 2009, 14:06
Location: Gdansk / Poland
Contact:

Slashes in article/category alias may cause rewrite problem

Post by adamderesz »

Hi,
Perhaps someone will find it interesting so when using slashes in article or category alias AND rewrite, at some point our backend may behave weird - ie ckeditor may not load showing 'page not found' message instead.
I don't know if it's a bug, I'd rather note it as a tip for all that didn't notice it, yet.

The solution for such is quite simple
In our site root .htacces file there is a line disabling rewriting the 'system' directories... yet it must be placed after all our conditional redirects and before final htm to php redirect... just like below

Code: Select all

RewriteRule ^en(/?)$ index.php?en
RewriteRule ^section(/?)$ index.php?section
RewriteRule ^(include|img|template|picture|filearchive|content)/ - [L]
RewriteRule ^(.+)\.html$ index.php?$1&%{QUERY_STRING}
Let's say we have a redirect to cleanup non-full url of site.com/en or site.com/en/
and cleanup url for any other section, say.. site.com/section/ so it will show like this instead of section.html which is the native alias for it (yer all its children have slashed alias including section/ in front)
all such 'hard-coded' redirects or rules must be placed BEFORE we check-up on 'system folders' present in our url
after that we ensure in line 3, so if link points to system elements (ie ckeditor or directly to our uploaded files - rewrite will not touch it ([L] at the end means it's the last rule to apply in a queue)
and then, for all the rest that did not match the rule above - we carry on with rewrite 'play' to cheat the browser and use sweet and near url

cheers
...and happy new year ;)

Adam
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Re: Slashes in article/category alias may cause rewrite prob

Post by Oliver Georgi »

maybe there is something in your Apache setting that handles /en/ by itself?

In general slashes used inside alias are part of the alias — so you cannot strip parts off and link to single segment.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
adamderesz
Posts: 19
Joined: Sat 3. Oct 2009, 14:06
Location: Gdansk / Poland
Contact:

Re: Slashes in article/category alias may cause rewrite prob

Post by adamderesz »

No, the slashes in alias work fine ...despite they are hand made ;)
The trouble I found was so when a standard order of htaccess rewrite commands was used - it did not process the 'directory exclusions' properly as it was before all other 'cleanups', so when added more rewrite commands (ie to make permament redirects from old gone content to new ones - simple link play) it went bogus on backend site showing 'page gone' content in place where fckeditor should appear

So for proper handling the 'directories exclusion' command for rewrite must be placed after all additional redirects we make, just that
...a tip for ones that may have similar problem and cannot find solution ;)
A.
Post Reply