Feature (closed)

discussing clean urls

Summary

closed
Sep 29, 2006
100%
Apr 15, 2012
Sep 29, 2006 / pixtur
Apr 15, 2012 / pixtur
pixtur
 

Attached files

No files uploaded
 
Some support of clean urls has been implemented. See this link:

Earlier Discussionπ

Actually the way streber handles pages would very well fit together wit clean urls:

The url:

 http://streber.pixtur.de/index.php?go=taskView?tsk=234

could be written as...

 http://streber.pixtur.de/task/234

or even

 http://streber.pixtur.de/234


Suggestionsπ

from .htaccess

...
RewriteEngine On

RewriteRule ^task/(.*)/$ index.php?go=taskView?tsk=$1 [L]
...


Stay compatibleπ

As mod_rewrite is disabled by default, we should make sure, that streber is working without it. We can add an config-option "USE_CLEAN_URLS" which is been set automatically on fresh installations.

If the admin of a streber installation is sure, that mod_rewrite is installed, he could add the line confChange("USE_CLEAN_URLS",true); to the customize.inc.php.

Retro style links with index.php?go= should still work, even if USE_CLEAN_URLS is true.


Mapping requestsπ

Single Item Idsπ

http://www.streber-pm.org/123

from .htaccess

RewriteRule ^(d+)/$ index.php?go=itemView?item=$1 [L]

Since every item in streber has a unique ID we detect it's type on the fly. Since all links inside streber are build by $PH->getLink() and $PH->getUrl() changing the link style would be straight forward:
  1. add additional option use_as_item_view to page-handles that are preferred views of items: taskView, effortView, etc.
  2. add wrapperFunction std/class_pagehandler.inc.php -> itemView() that queries the item type by... if($item= DbProjectItem->getVisiblebyId($id)) { $type= $item->type; } and does a mapping to the appropriate view function: $page=$g_handles[$type."View"]; if(isset($page)) { $PH->show($page);}
This would reduce html code and make most urls pretty clean.

Submitting POST dataπ

Each page has a <form> element which is rendered in render/render_page.inc.php:

from render_page.inc.php

$buffer= '<form name="my_form" action="index.php" method="post" enctype="multipart/form-data" >';

When USE_CLEAN_URLS index.php should be renamed to submit or the go parameters inside the POST data.


Other pagesπ

The format of other urls needs some discussion...

 
http://www.streber-pm.org/index.php?go=taskEdit&tsk=234
 might become...
   http://www.streber-pm.org/taskEdit/234
   http://www.streber-pm.org/234/edit
   http://www.streber-pm.org/234/edit/format=pda

   
http://www.streber-pm.org/index.php?go=projViewTasks&prj=2&preset=my_open
 might become...
   http://www.streber-pm.org/2/viewTasks/preset=my_open
   http://www.streber-pm.org/2/viewTasks/my_open

http://streber.pixtur.de/index.php?go=taskEditDescription&tsk=2267&from=b0023237383c29ff6b7fdb20a5fa7061
 might become...
   http://streber.pixtur.de/2267/editDescription/from=b0023237383c29ff6b7fdb20a5fa7061


15 Comments

tino:we could do this with...

11 years ago

mod_rewrite

This solution would be quite cool

binder:mod_rewrite is your friend

11 years ago

but we have to add some way to get the variables out of the url and to write these urls. I can write some more on this issue next week.

pixtur:I added some description...

11 years ago


pixtur:hi binder...

11 years ago

Any updates on this one? I am very interessted in that feature...

pixtur:implemented some part but...

11 years ago

I am very happy with the implementation of the first step. Sometimes programming is fun. Actually I just had to adjust the Pagehandler->getUrl() function and provide information for each pagehandle on how it should be rendered as a clean url. Like...

from pages/_handles.inc.php

new PageHandle(array('id'=>'taskView',
    'req'=>'pages/task_view.inc.php',
    'title'=>__('View Task'),

    'test'=>'yes',
    'test_params'=>array('tsk'=>'_taskView_',),

    'cleanurl'=>'_ITEM_',
    'cleanurl_mapping'=>array('tsk' => '_ITEM_'),

));

When requesting urls from the Page handler it checks if the requested page id has a cleanurl setting and if USE_MOD_REWRITE is enabled. Then he goes through the parameters and cleanurl_mapping and replaces all mapped varibable occurences in the cleanurl.

Problem:π

  • What seems to be tricky is the rendering of multiple attributes like:

 www.pixtur.de/23/tasks

Although I could parse this somehow, after building the new page, all urls to items (which where perfectly valid before) like="24" now point to "23/24" just as if 23 would be a real directory. I am stuck with this and need some help of an Apache guru ,-)


pixtur:I would consider to be complete...

11 years ago

Maybe we sould write some documentation for it.

madlyr:I love this stuff and all urls should be 'cleaned' :-)

11 years ago

I use it just from moment I saw it on streber site :-) I think all urls' shoould be filtered and cleaned.

madlyr:'clean url' vs. SEF (Search Engine Friendly)

11 years ago (2. update 11 years ago)

In Mambo / Joomla this has much better name SEF - Search Engine Friendly urls. It is woth of note OpenSEF module to Joomla here.

Yes it doesn't matter if something useful is named A or B but for a lot of people clean url will be new name, SEF is much more known in php environment :-)

Just my 2 cents :-).

madlyr:Problem with trailing /

11 years ago

Still there is problem to get worked clean urls ending with trailing /.

http://streber.pixtur.de/2647 works good, but http://streber.pixtur.de/2647/ is not working.

I see in .htaccess some rules about this, I checked some rules form Joomla but still I didn't get proper results. It is important to get trailing "/" working.

madlyr:submit at end of url after editing something

11 years ago

If you edit task and get submit, then we go to the task page with url suffix /submit. Any refresh of this page gives problem, bookmarking page gives problem (bookmark http://streber.pixtur.de/submit and see this error).

I think after submitting anything we should reload page or rewrite page url that page does not contains submit suffix.

Only form url or directly submitting using get parameters should contain submit suffix.

pixtur:Regarding Submit problem and more Clean urls...

11 years ago

Namingπ

Well, I don't care how this is called. If you google...
  • "clean urls" - 1.290.000 results
  • "Search Engine friendly urls" : 2.350.000 results
You won :)

More Urlsπ

I would very much like to have more SEFUs but I just didn't get it to work. Somehow the browser got the "/32" as a new subdir and failed loading the stylesheets. Maybe I am just too stupid, but after some hours, I just didn't care anymore...

I would love, if you could give it a try...

Do you need any more documation to the code?

Submit bug...π

I already noticed this bug a lot of times and will fix this behavior.

madlyr:Yes please add some more nfo

11 years ago

from cite

More Urls
I would very much like to have more SEFUs but I just didn't get it to work. Somehow the browser got the "/32" as a new subdir and failed loading the stylesheets. Maybe I am just too stupid, but after some hours, I just didn't care anymore...

I would love, if you could give it a try...

Do you need any more documation to the code? 

Yes I do, please.

pixtur:I put it on my todo list...

11 years ago

sorry for being too slow at the moment

deizel:Joomla! 1.5

11 years ago

You guys might want to have a look at what Jinx has come up with before you go implementing human readable URIs.

http://forum.joomla.org/index.php/topic,140836.msg687957.html#msg687957

pixtur:Antwort auf Joomla! 1.5

11 years ago

I will have a look at it. Thanks.