Page 1 of 1

mod_rewrite problem

Posted: Sat Jun 02, 2007 4:38 pm
by kraen
Hi
I'm using the latest CMSM build. I want to make SEF URLs so i headed for the CMSMS FAQ and did as they said, but that didn't work out.

I am 100% sure, that my server supports mod_rewrite because my Wordpress blog works fine.

I have NO idea what to do. I have tried altering my htaccess file but I still get the 500 internal server error. I have searched this forum but nothing worked for me.

My config file:
#------------
#URL Settings
#------------

#Show mod_rewrite URLs in the menu? You must enable 'use_hierarchy' for this to work for modules
$config['assume_mod_rewrite'] = true;

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

#If you don't use mod_rewrite, then would you like to use the built-in
#pretty url mechanism?  This will not work with IIS and the {metadata} tag
#should be in all of your templates before enabling.
$config['internal_pretty_urls'] = false;

#If you're using the internal pretty url mechanism or mod_rewrite, would you like to
#show urls in their hierarchy?  (ex. http://www.mysite.com/parent/parent/childpage)
$config['use_hierarchy'] = true;

#If using none of the above options, what should we be using for the query string
#variable?  (ex. http://www.mysite.com/index.php?page=somecontent)
$config['query_var'] = 'page';

My htaccess: (I got this one from another user on this forum)


  # Enable URL rewriting
 
  RewriteEngine on
  RewriteBase /

  # Rewrite URLs of the form 'index.php?page=x&print=true':

  # RewriteCond %{REQUEST_FILENAME} !-f
  # RewriteCond %{REQUEST_FILENAME} !-d
  # RewriteRule ^print/(.*)$      index.php?print=true&page=$1 [L,QSA]

  # Rewrite URLs of the form 'index.php?page=x':

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$            index.php?page=$1 [L,QSA]


  # Rewrites /page.php as /page
  #RewriteRule ^/?(.*)\.php$ $1 [QSA]

  # Rewrites /page as index.php?page
  #RewriteRule ^([^/]*)$    index.php?page=$1 [L,QSA]

  # Disables admin rewriting
  #RewriteRule ^/?admin/?$  /admin/index.php [QSA]


Re: mod_rewrite problem

Posted: Tue Jun 05, 2007 3:04 pm
by Pierre M.
Hello,

it seems OK.
You have installed CMSms at the root (/) of your hosting, haven't you ?

Beware the order of the lines matters in .htaccess.
Can you show your http error log which triggers this 500 error ?

Please try those little tests :
http://forum.cmsmadesimple.org/index.ph ... l#msg43943
and tell us what is working, what is not (not in the tests' thread please).

Pierre M.

Re: mod_rewrite problem

Posted: Wed Jun 06, 2007 2:59 pm
by kraen
No actually I have placed my CMS in a subfolder but the htaccess is also in the subfolder

The 404 works fine but the RewriteRule won't work.

As stated in the first post I am 100% sure that mod_rewrite works fine.

Re: mod_rewrite problem

Posted: Wed Jun 06, 2007 3:42 pm
by Pierre M.
May be the RewriteBase doesn't match the subfolder ?
To diagnose the 500 error it would be helpfull to see the http error log.

Pierre M.

Re: mod_rewrite problem

Posted: Thu Jun 07, 2007 6:24 pm
by kraen
Let me get this right:
I place my .htaccess in a subfolder with the parameter:
RewriteBase /

Isn't that correct?

or should it be:

RewriteBase /subfolder?

Re: mod_rewrite problem

Posted: Thu Jun 07, 2007 6:43 pm
by Pierre M.
I am not sure about this. Please try both.
But this should not trigger a 500 error. What is the text of this 500 error ? from Apache or CMSms ?

Pierre M.

Re: mod_rewrite problem

Posted: Thu Jun 07, 2007 7:06 pm
by kraen
After a bit testing i have come to the following:

This solution works:
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f [NC]

RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

This doesn't work:
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

Re: mod_rewrite problem

Posted: Thu Jun 07, 2007 7:15 pm
by kraen
This works:
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]