friendly URLs [Working now]

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
sammex

friendly URLs [Working now]

Post by sammex »

I would like to get friendly URL's working on my site, and I think from CMS's side I've done what is needed, but Apache isn't cooperating (I'm getting 404 errors from the menu-generated links).

I've copied doc/htaccess.txt to .htaccess. I've edited config.php, for $config['assume_mod_rewrite'] = true;

From my httpd.conf:

        Options FollowSymLinks
        Allow on
        DocumentRoot /var/www/html/
        ErrorLog logs/error_log
        ServerName www.mysite.com
        ServerAlias mysite.com
        TransferLog logs/access_log
        DirectoryIndex index.html index.php index.htm index.shtml


and
LoadModule rewrite_module modules/mod_rewrite.so


Any thoughts?
Last edited by sammex on Tue Aug 09, 2005 9:26 am, edited 1 time in total.
100rk

Re: friendly URLs

Post by 100rk »

sammex wrote: Any thoughts?
Try to include directive

Code: Select all

AllowOverride All
into definition of You virtualhost directory - see this document: http://apache.active-venture.com/mod/co ... owoverride
sammex

Re: friendly URLs

Post by sammex »

I've got a little success but not much yet. First, I moved the rules into my server's httpd.conf file. Second I added some rewrite debugging (logging at verbosity 9).


From my log:
[09/Aug/2005:04:23:10 --0400] [www.mysite.com/sid#9c42918][rid#9e24290/initial] (2) init rewrite engine with requested uri /Home.shtml
[09/Aug/2005:04:23:10 --0400] [www.mysite.com/sid#9c42918][rid#9e24290/initial] (3) applying pattern '^(.*)\.shtml$' to uri '/Home.shtml'
[09/Aug/2005:04:23:10 --0400] [www.mysite.com/sid#9c42918][rid#9e24290/initial] (2) rewrite /Home.shtml -> index.php?page=/Home
[09/Aug/2005:04:23:10 --0400] [www.mysite.com/sid#9c42918][rid#9e24290/initial] (3) split uri=index.php?page=/Home -> uri=index.php, args=page=/Home
[09/Aug/2005:04:23:10 --0400] [www.mysite.com/sid#9c42918][rid#9e24290/initial] (2) local path result: index.php

Notice the local path result 'index.php' -- which should be ok, since my CMS is at the root of the server. I changed my rewrite rule to add a leading slash, just for good measure though:
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (2) init rewrite engine with requested uri /Home.shtml
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (3) applying pattern '^(.*)\.shtml$' to uri '/Home.shtml'
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (2) rewrite /Home.shtml -> /index.php?page=/Home
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (3) split uri=/index.php?page=/Home -> uri=/index.php, args=page=/Home
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (2) local path result: /index.php
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (2) prefixed with document_root to /var/www/html/index.php
[09/Aug/2005:04:24:26 --0400] [www.mysite.com/sid#9219918][rid#93fb270/initial] (1) go-ahead with /var/www/html/index.php [OK]

Now, this almost works... except that I end up with a 100% white page where a viewing of the source results in:



Of course, http://www.mysite.com/index.php?page=Home results in a proper page being served up.

Clearly cmsms is being reached, but with what, I wonder?
sammex

Re: friendly URLs

Post by sammex »

Ok, I turned on CMS debugging, and was given:
SELECT * FROM cms_content WHERE content_alias = '/Home' AND active = 1

SELECT c.content_id, c.cachable, t.modified_date as template_date, c.modified_date as content_date, c.type, c.hierarchy, t.encoding FROM cms_content c INNER JOIN cms_templates t ON t.template_id = c.template_id WHERE c.content_alias='/Home' AND c.active = 1


..... well, here's the problem. content_alias is being searched for as /Home, but it appears as Home (no slash). Argh!

I'm at a loss for what else to try/dig up.
nils73
Power Poster
Power Poster
Posts: 520
Joined: Wed Sep 08, 2004 3:32 pm

Re: friendly URLs

Post by nils73 »

It seems that your provider has some general settings activated that override your htaccess-settings. I had the same problem but I could convince my provider (who is a friend of mine) to change my setting so that I can use mod_rewrite and stuff like that via htaccess. If you have a .htaccess that doesn't allow things on a global level, it might block things one level below.

Regards,
Nils
sammex

Re: friendly URLs

Post by sammex »

I am the provider in this case (my box, on a static IP), so I can change configuration if I only know what to change ;)

I just got this thing working! I currently have the config in the main server configuration (in the VirtualHost section for this root) with this rewrite rule:
    RewriteRule ^/(.*)\.shtml$ /index.php?page=$1 [QSA]

The change from the one in cmsms's htaccess.txt are the two forward slashes.

I suspect now that I've got a working rule I can relocate it to the local .htaccess, but is there any particular benefit to it being there (considering, as mentioned, editing the global .conf is not a problem)?
100rk

Re: friendly URLs

Post by 100rk »

Try include directive

Code: Select all

RewriteBase /
Locked

Return to “CMSMS Core”