(solved!) Problem with mod_rewrite

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.
Post Reply
Durandir
New Member
New Member
Posts: 6
Joined: Thu Nov 22, 2007 8:46 am

(solved!) Problem with mod_rewrite

Post by Durandir »

I am in need of some help. This is one of my first websites (the previous ones have been very simple without any flashy stuff), and this is my first time using CMS. I am making a site for the local bowling club. I made it in normal html first, using Dreamweaver, and then I found out about CMS. Which is more or less required, since the leader of the club wants to update pages on the fly during tournaments and such.
So I remade the site after installing CMS. (The directory for it is like this: server/Hallingkast) I do not host the server, but I know it is a Linux server, with PHP enabled.

Now, I have made all the new pages, they are all different, since I haven't learned enough to use tabbed panels on one page etc (spry tabs I think it was called) I know virtually nothing about code yet, and I am learning slowly. I called the new main page index, and then just used that as the parent site. So when I go to the preview page for the index-site, I have all of the other sites in the menu. Every link worked fine. Then I added the .htaccess file, and tried to enable mod_rewrite and pretty urls. Now everything almost works fine. The thing that does not work, is the links. When trying to go anywhere, I get this error:
Not Found

The requested URL /index/klubbrekorder/ was not found on this server.
Apache/2.0.59 (Unix) mod_ssl/2.0.59 OpenSSL/0.9.7d DAV/2 PHP/4.4.4 PHP/5.1.4 Server at www.hallingkast.no Port 80
I am sure there is something very simple I have missed, but having no coding experience, I just have no idea what.
This is my .htaccess file (which I have scrounged from this forum, in trying to figure out what was wrong):

  # 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]
Last edited by Durandir on Thu Nov 22, 2007 11:08 am, edited 1 time in total.
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Problem with mod_rewrite

Post by kermit »

put {metadata} in the of your template, underneath {stylesheet}

start with trying ONLY the rewrite rules in the sample htaccess file located in the doc directory.. they are:

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

#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]


config.php's url section should look something like this:

Code: Select all

#------------
#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'] = '/';
# leave it empty or suggested alternatives are either / or .html

#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;
#optional, default is false

#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';
clear the cmsms cache.
Last edited by kermit on Thu Nov 22, 2007 10:46 am, edited 1 time in total.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Durandir
New Member
New Member
Posts: 6
Joined: Thu Nov 22, 2007 8:46 am

Re: Problem with mod_rewrite

Post by Durandir »

Really appreciate the help ^^

Ah, the {metadata} tag was placed just above {stylesheet}
Not sure how much that matters, but I moved it at least.

The .htaccess file with only those lines work at least. But it did not solve my problem.
And that is just how my config.php looks like.

After everything looks like that, clearing the cache does not help.
Anything else I can try?
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Problem with mod_rewrite

Post by kermit »

add the first line below to the htaccess.


Options +FollowSymLinks

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

#Rewrites page.shtml as index.php?page
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Durandir
New Member
New Member
Posts: 6
Joined: Thu Nov 22, 2007 8:46 am

Re: Problem with mod_rewrite

Post by Durandir »

Sorry for doubleposting, but I found out something more. I tried to make a test-site using the news module. This was not a page under my index page, yet it showed on the menu of course. And it works. So it's only the pages under index (index/somepage) that does not work. I thought the hierarchy line in config.php enabled that?

Ah, not a doublepost after all :P

Tried that, did not work. :/
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Problem with mod_rewrite

Post by kermit »

i'd suggest NOT having all the pages underneath "index" anyway.. /index/somepage/someotherpage just looks weird and 'index' in these cases doesn't add anything 'useful' or descriptive to the url.

put main pages at the root level of the hierarchy (same level as 'index') is; then put related sub pages underneath their respective parent pages.

edit: just tested adding a subpage to a default page aliased as 'index' and www.mydomain.com/index/subpageofindex/ did work.. but if you can get around your problem by moving those pages up a level in the hierarchy... that sounds good to me! ;)


edit 2: woohoo! i see pages on your site.
Last edited by kermit on Thu Nov 22, 2007 11:07 am, edited 1 time in total.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Durandir
New Member
New Member
Posts: 6
Joined: Thu Nov 22, 2007 8:46 am

Re: Problem with mod_rewrite

Post by Durandir »

Wow. That fixed it. Thank you so much!
Would be nice for me as an admin to hide the existing CMS pages there though. I want them there as reference for things I might have to do, and I think those who are going to run the site would like it to be as clean as possible. But as long as it works for now I am happy ^^
So thanks again!
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: Problem with mod_rewrite

Post by kermit »

Durandir wrote: Wow. That fixed it. Thank you so much!
Would be nice for me as an admin to hide the existing CMS pages there though. I want them there as reference for things I might have to do, and I think those who are going to run the site would like it to be as clean as possible. But as long as it works for now I am happy ^^
So thanks again!
if you have pages you don't want other editors modifying, then don't give them access to do so. create new back-end user accounts for those editors and add them individually as 'additional editors' on the specific pages you want each to be able to edit. when those limited editors login to the admin panel and bring up the list of pages, ONLY the pages they can edit will be shown.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Durandir
New Member
New Member
Posts: 6
Joined: Thu Nov 22, 2007 8:46 am

Re: (solved!) Problem with mod_rewrite

Post by Durandir »

Hey, thanks for that as well ^^
Post Reply

Return to “CMSMS Core”