Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help test a possible future change.
#1
Today I submitted a new pretty URL .htaccess up for review to see if we can make GetSimple just a tiny bit better again. But before we want to put a change like this into the core we want to make sure we aren’t breaking anything.

Don’t you mind testing a new piece of code to help make GetSimple better? Great! I’ll tell you how to plug this into your installation and you’ll tell us if anything breaks.

Open up your .htaccess file, you’ll find it in the root. In it you look for this line:
Code:
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
Now replace it with this:
Code:
RewriteRule ^((.+/)?(.+?)/?)$ index.php?path=$1&id=$3 [QSA,L]

What has changed for you? Nothing visible.

The only change you should notice is faulty URLs like http://example.ms/example== now show the GetSimple 404 page. (Try it without the above change, you’ll see your server’s default 404 page.)

What has changed for developers? Everything!

We now have access to the full URL that has been requested. This means plugins like I18N no longer need to ask you to change the .htaccess. It also means we can start to slowly work on supporting Unicode support (finally slugs in your own language!) or things like URL shorteners (screenshots of URL shortener, only when you’re logged in).

So how do I use this in my upcoming plugin?

Here’s a very simple example. This would be how I18N can check what language is requested:
Code:
$path = explode('/', rtrim($_GET['path'],'/'));
if ( count($path) > 0 ) {
   $language = $path[0];
}
After this $language contains a string of the first directory in the URL, which would be “en” on the English page http://example.ms/en/home.

Please leave a comment here or on the issue in the bug tracker with your thoughts and error reports.

› Edit: now includes a working (or not, depending how you look at it) example of getting the server’s default 404 page. Updated RewriteRule inspired by comments, read more a little down.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply


Messages In This Thread
Help test a possible future change. - by Zegnåt - 2012-03-25, 02:02:03
Help test a possible future change. - by hameau - 2012-03-26, 20:54:08
Help test a possible future change. - by Carlos - 2012-03-26, 23:52:13
Help test a possible future change. - by mvlcek - 2012-03-27, 00:39:54



Users browsing this thread: 1 Guest(s)