Page 3 of 4

Re: Clean Hierachical URL's

Posted: Thu Apr 20, 2006 3:09 am
by iNSiPiD
So this will work for all relative paths in a page and absolute paths won't be affected at all, right?

And it's XHTML-compliant. w00t!

Re: Clean Hierachical URL's

Posted: Thu Apr 20, 2006 8:40 am
by Russ
Thanks Ryno for the explanation, if I'd been concentrating on this a bit more, rather than my washing machine, or rather my 'non-washing - oo I won't let you get your washing out' washing machine, then perhaps I would have understood Ted's perfectly reasonable explanation. Thanks - both of you. Just in case anyone else missed the idea, just put {metadata} in the section of your template. When the page is created it has a

Code: Select all

<base href="http://localhost/cms/" />
in the header. (Note the actual path will vary.)

I've been having a play and pretty much everything seems funky, even ImageManager works now. (It's a pity it doesn't use the friendly url's like the rest of the site - but it works!) Yes iNSiPiD, it does validate, at least to XHTML Strict 1.0.

There are is only one small and one slightly bigger problem that I can see at present:
1. If, like me, you use something like this in your footer:

Code: Select all

<a title="Jump to Top" href="#content"> Top </a>
Then it will no longer work. You will get something like:

Code: Select all

http://localhost/cms/#content
as the link, which will jump you back to your home page. I'm open to suggestions on this one, but it could be a case for a 'top' option in CMS_SelfLink jumping to the contents div? Any other ideas?
This may well apply to other bookmarks? SEE BELOW

2. PiSearch no longer works, you get blank links. Whilst I appreciate this is not 'our' code, we do need a search engine and this worked. I've had a look at the code :( and can't see an obvious way of fixing this. Does anybody have any other ideas? SEE BELOW!


I've got to say this is all a very cool for CMS. I'm excited...When Ted gets the 0.13 betas up. I'll put it up on our test site so people can see how funky it really is. I've not tried the FCK internal link thing yet as it is not in my version. Also I haven't tried any other add-ins like 'news' because I don't use them, but am willing to put them on the test site if people think it will help?

UPDATE: 0.13BETA 1 is up on our test site. Includes freindly url's for piSearch (updated verson), updated cms_selflink for internal links, (Look at footer links)
http://www.cms.shoesforindustry.net

Russ
P.S. That's another big pat on the back Ted, anymore and you'll be badly bruised  - but what a way to go...

Re: Clean Hierachical URL's

Posted: Sat Apr 22, 2006 7:38 pm
by Bealers
The addition of this feature has made it certain that this is the CMS for me.

I can confirm that with a config.php of:

Code: Select all

$config['assume_mod_rewrite'] = true;
$config['page_extension'] = '';
$config['internal_pretty_urls'] = false;
$config['use_hierarchy'] = true;
an .htaccess file containing:

Code: Select all

RewriteEngine On
Options FollowSymLinks
# set this to be an absolute path from your webservers document root
# if you've installed CMS into /foo then set this to /foo
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
and making sure that Apache will take notice of your .htaccess file, in my VirtualHost container I added:

Code: Select all

<VirtualHost xxx.xxx.xxx.xxx>
..
<Directory /path/to/doc/root/>
    AllowOverride All
</Directory>
...
</VirtualHost>
It all works fine, this was on an svn version of the codebase "0.13-beta1"

Guys, I've got to say that as a web developer looking for something:
  • that Just Works
  • is easy to skin
  • where I don't need/want to read the manual
  • has standards compliant innards
  • has a healthy community
  • where I could point a client at the admin interface from an (almost) vanilla install
...CMSms ticks all the boxes.

Thanks++, I hope to be able to contribute something back in the near future.

Re: Clean Hierachical URL's

Posted: Mon Apr 24, 2006 4:22 pm
by Elijah Lofgren
Bealers wrote: Guys, I've got to say that as a web developer looking for something:
  • that Just Works
  • is easy to skin
  • where I don't need/want to read the manual
  • has standards compliant innards
  • has a healthy community
  • where I could point a client at the admin interface from an (almost) vanilla install
...CMSms ticks all the boxes.

Thanks++, I hope to be able to contribute something back in the near future.
My sentiments exactly!  ;D

Re: Clean Hierachical URL's

Posted: Tue Apr 25, 2006 9:15 pm
by hansom
Bealers wrote:

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
If I use this, requests for the root url made without the trailing slash fails. For example, a request for http://www.example.com/cms results in a 404 but http://www.example.com/cms/ (including the trailing slash) works. Do you have any idea what causes this?

Re: Clean Hierachical URL's

Posted: Tue Apr 25, 2006 11:39 pm
by iNSiPiD
I can't seem to use the generic regex (.+) either and find the following two rules to be necessary for the rewrite. Note the forward slash in the first rule. A question mark in front of the forward slash also works as an 'if exists' and may be required by some servers.

RewriteRule ^([a-zA-Z0-9-]+)/$ /$1 [R]
RewriteRule ^([a-zA-Z0-9-]+)$ /index.php?page=$1 [NC]

You could also try:

RewriteRule ^(.+)/$ /$1 [R]
RewriteRule ^(.+)$ /index.php?page=$1 [NC]

Re: Clean Hierachical URL's

Posted: Wed Apr 26, 2006 8:54 am
by hansom
iNSiPiD wrote: I can't seem to use the generic regex (.+) either and find the following two rules to be necessary for the rewrite.
Alas, I get the same result using your suggestions. A request for http://example.com/cmsms results in a 404 error trying to get the url http://example.com/cmsms/?page=/var/www/pub/cmsms

Re: Clean Hierachical URL's

Posted: Thu Apr 27, 2006 3:39 pm
by hansom
OK, what seems to do the trick, in my case anyway, is this:
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]

Re: Clean Hierachical URL's

Posted: Thu Apr 27, 2006 5:22 pm
by Russ
Mmmmm.... the sheer 'black magic art' of Mod Rewrite ;-*

Re: Clean Hierachical URL's

Posted: Fri Apr 28, 2006 12:49 am
by iNSiPiD
Tell me about it. The simplest rewrites using stock standard examples from Apache's website invariably require a tweak somwehere. Such is the sheer beauty of the http.conf file.

Re: Clean Hierachical URL's

Posted: Sat Apr 29, 2006 8:42 pm
by Elijah Lofgren
I wanted the following:
Here's what works for me:

In config.php

Code: Select all

#Show mod_rewrite URLs in the menu?
$config['assume_mod_rewrite'] = true;

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '/';
In .htaccess

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off

Options +FollowSymLinks
RewriteEngine on

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/ 
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
Hope this helps someone.

Re: Clean Hierachical URL's

Posted: Sun Apr 30, 2006 10:55 pm
by iNSiPiD
Using a trailing slash for the file extension paramter in config.php was a very clever piece of work.

Ted, is this an acceptable usage or is it likely to break something down the track?

Re: Clean Hierachical URL's

Posted: Mon May 01, 2006 12:57 am
by Ted
I don't see it being an issue.  It's rather slick, actually.  The url parsing code strips off any trailing slashes, so CMSMS should just ignore it.

Re: Clean Hierachical URL's

Posted: Mon May 01, 2006 1:14 am
by Ryno
Hey Elijah,

Just tried your .htaccess settings and they work great for me.

Only problem is when I try to access /admin or admin/ I get a 404 error? Try http://www.seventhvision.com.au/cms/admin

Is this something I'm doing wrong is is this just a result of getting prety urls to work and I can just work around it?

Ryno

Re: Clean Hierachical URL's

Posted: Tue May 02, 2006 11:01 pm
by iNSiPiD
The rewrites above only account for existant files, not directories.

You need to create a rule for each directory you'd like access to. This also has the side affect of disallowing entry to folder views which, in most cases, is a good thing.

Just throw this into your htaccess file above the main rewrite rules.

RewriteRule ^/?admin/?$ /admin/index.php [R]