Improved clean url trick

General project discussion. NOT for help questions.
ljbadenz

Improved clean url trick

Post by ljbadenz »

I am getting frustrated whit cmsms i've just installed it and are trying to set up some pages, but the error appears in the edit box thing - see screen shot.
It appears for 1 second then dissapears and all seems to be working well.
Except if I create an image, it says "no content" when I submit.

I aslo get an errormessage in the html code popup:

Warning: Smarty error: unable to read resource: "db:modules/TinyMCE/tinymce/jscripts/tiny_mce/themes/advanced/source_editor" in /home/www/ibbs/cmsmadesimple/lib/smarty/Smarty.class.php on line 1088

The only thing ive changed is add the .htacess file to enable the tidy url - I had to comment the php settings lines at the top or else my webserver stops working.

I enabled in config.php, in both htacess and config i changed the extension from .shtml to htm.

Ill try and diable it again and see if that amkes a difference.
---
I disabled it and it works... hmmm I wonder if its the page_extension setting its so touchy about. I'll investigate and return.

[attachment deleted by admin]
Last edited by ljbadenz on Thu Jul 14, 2005 7:12 am, edited 1 time in total.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Error message in /admin/addcontent.php

Post by Ted »

The problem is that a few of the things in TinyMCE are based on htm files.  So, everytime it tries to open an htm via javascript, the server is running it through CMSMS instead...  That's why we use the shtml extension because it causes no conflicts.  There apparently is a way to get mod rewrite to only rewrite if it's sure the file doesn't phsyically exist first, but that's left as an exercise to the reader.  (and if you do get it working, please post the results!).
ljbadenz

Re: Error message in /admin/addcontent.php

Post by ljbadenz »

wishy wrote: That's why we use the shtml extension because it causes no conflicts.
It works with shtml I jsut checked so ok, it was me trying to be clever and using .htm...
wishy wrote: There apparently is a way to get mod rewrite to only rewrite if it's sure the file doesn't phsyically exist first, but that's left as an exercise to the reader. (and if you do get it working, please post the results!).
I'll try and research this...
ljbadenz

Re: Error message in /admin/addcontent.php

Post by ljbadenz »

[glow=red,2,300]I finally got the .htaccess file to work with .htm extension, and for that matter any extension![/glow]

OK, now listen carefully this is what you do (make sure you double check what you paste)

Here goes:
1. Follow the instructions in the wiki and setup tidy urls.

2. Edit your .htaccess file like so:

Code: Select all

php_flag magic_quotes_gpc Off
php_flag register_globals Off
php_flag session.use_trans_sid Off

# Make sure you have Options FollowSymLinks
# and Allow on
RewriteEngine On


#Rewrites page.shtml as index.php?page
#If page.shtml already exists as a file, then does not rewrite the URL
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.+)\.shtml$ index.php?page=$1 [QSA]
Note the new line

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-f [NC]
This conditionally checks to see if there is a fille with the samename in the directory, if there is it doesnt rewrite the URL. This enables TinyMCE to read the files it wants with out apache changing the URL on it.

Now if you want to change the extension to .htm or anything for that matter do this:
1. Edit the .htaccess file by changing the RewriteRule to this:

Code: Select all

RewriteRule ^(.+)\.htm$ index.php?page=$1 [QSA]
2. Edit your config.php by changing the 'page_extension option to this:

Code: Select all

$config['page_extension'] = '.htm';
Now the tidy URL code is flawless, as far as I can see.

I've attached the modded .htaccess file using .shtml. Be sure to rename it to .htaccess.

For the admins/programmers:
Update the wiki tips and tricks to include this new information.
Change the /doc/.htaccess.txt file in CMSMS to eh new one attached.


[attachment deleted by admin]
Last edited by ljbadenz on Fri Jul 15, 2005 4:51 am, edited 1 time in total.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Error message in /admin/addcontent.php

Post by Ted »

That's great.  I'll add it to svn so it's in the next release.  Thanks!
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Error message in /admin/addcontent.php

Post by Ted »

I've committed this to svn and also changed the defaults to .html

nice work!
ljbadenz

Re: Improved clean url trick

Post by ljbadenz »

I've updated the wiki.
ljbadenz

Re: Improved clean url trick

Post by ljbadenz »

Well done.
I see you managed to figure out the php.
Hope whishy takes some notice of this!
ljbadenz

Re: Improved clean url trick

Post by ljbadenz »

I dont know the exact internal workings of cmsms, maybe whishy could fix it when he puts it into the svn.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Improved clean url trick

Post by Ted »

Use $this->cms->config instead.  Same with page_extension.
100rk

Re: Improved clean url trick

Post by 100rk »

Nice cheat-sheet for mod_rewrite:

http://www.ilovejackdaniels.com/cheat-s ... eat-sheet/

Other (PHP, MySQL, CSS, RGB Hex colour chart) are here:
http://www.ilovejackdaniels.com/cheat-sheets/
Post Reply

Return to “General Discussion”