Page 1 of 2

stupid problem with pretty urls

Posted: Wed Mar 28, 2007 7:07 pm
by piotrekkr
Hi. I've got problem with pretty url's in my module:
my SetParameters():

Code: Select all

function SetParameters(){
	$this->RegisterRoute('/uniwerki\/(?P<user_action>[a-z_]+)\/(?P<returnid>[0-9]+)$/', array('action'=>'login_form'));
}
I'm creating a link to login form:

Code: Select all

echo $this->CreateLink($id, 'login_form',  $returnid, 'Login', array(), '', false, true, '', false, 'uniwerki/login_form/'.$returnid);
and when I click on it, action.default.php appears. Is this normal that always action.default.php is showed when using routes or my route is bad or something? Do action depends on array('action'=>'login_form') in second argument of RegisterRoute() function?

This is my .htaccess

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /cmsms/

# 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/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
and config.php

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'] = '/';

#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'] = true;

#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';
I searched forum many times  and I didn't find answer :(. Help please

PS Sorry for my poor english

Re: stupid problem with pretty urls

Posted: Thu Mar 29, 2007 8:52 pm
by Elijah Lofgren
Everything appears to be in order.
I would look at the routes in Album: http://viewsvn.cmsmadesimple.org/viewsv ... iew=markup

and Calendar:
http://viewsvn.cmsmadesimple.org/viewsv ... iew=markup

Maybe install one of them and make sure pretty URLs works with them.

I don't have time right now to try out your code.

Hope this helps,

Elijah

Re: stupid problem with pretty urls

Posted: Fri Mar 30, 2007 4:42 am
by piotrekkr
Hi I installed album module and he didn't work too :( the same is with news module. Is it possible that something is wrong with my apache? I have apache 2 on fedora core 6. It seems that mod rewrite works because I made .htaccess

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*$ [NC]
RewriteRule ^(.*)$ http://www.o2.pl/ [R]
and it redirect correctly. Maby I didn't configure correctly apache in httpd.conf. Could someone tell mi how to confiure it?? Thanks.

Re: stupid problem with pretty urls

Posted: Fri Mar 30, 2007 4:49 am
by Elijah Lofgren
I'm not sure why it wouldn't work.
You can install XAMPP for Linux, I used that on my old PC and it worked fine with mod_rewrite: http://www.apachefriends.org/en/xampp-linux.html

I currently run Ubuntu and it works (I think I did have to turn mod_rewrite on).

I'm not sure why it wouldn't work on Fedora. I've never used Fedora.

- Elijah

Re: stupid problem with pretty urls

Posted: Fri Mar 30, 2007 9:55 am
by Ted
Shouldn't your rewrite rules be:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*$ [NC]
RewriteRule ^(.*)$ http://www.o2.pl/index.php?page=$1 [R]
?

It seems like every page would redirect to the home page the way it is now.

Re: stupid problem with pretty urls

Posted: Fri Mar 30, 2007 8:10 pm
by piotrekkr
Yes i know that :) it was only a test to check if my mod rewrite works on my localhost :). Until now I was working local  but now I will use paid hosting so there shouldn't be any problems :) Thanks for help :)

Re: stupid problem with pretty urls

Posted: Sat Mar 31, 2007 1:40 am
by newagekat
Hi everyone:

I've used Pretty URLs on several sites and it works like a charm.  however, i'm currently working on site where CMSMS was installed in a directory, see http://www.living-excellence.com/climbKili.  This time, when i added the .htaccess script, i got this error message:

We are currently experiencing a higher than normal volume. Please wait 10 minutes or try again at a later time. Thank you

This message vanishes everytime I remove the .htaccess but keep the URL settings.  However, leaving the url setting without the .htaccess, results in a 404error except for the home page.

my .htaccess reads as follows:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /cmsms/

# 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/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]

my config file reads:

#------------
#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'] = true;

#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';

the files are correctly chmod and metadata is present in the template.  does anyone have any ideas?  Much apprecieate any input.  thanks.

Re: stupid problem with pretty urls

Posted: Mon Apr 02, 2007 2:45 pm
by Pierre M.
Hello,

Are all your sites hosted by the same provider ?
If not, I suspect the "directory" one has its own .htaccess tweaking incompatible with yours.

Pierre M.

Re: stupid problem with pretty urls

Posted: Mon Apr 02, 2007 4:24 pm
by newagekat
Hello Pierre:

thanks for replying.  Yes, all sites are on the same server.  Now, i did put the .htaccess file in the directory where cmsms is installed, not in root.  When i checked the instructions, i realize it has to be in root.  :-[ Per the FAQ instructions, I modified RewriteBase / with RewriteBase /climbKili/  now the root pages and the directory pages have been replaced with

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@living-excellence.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

???

Re: stupid problem with pretty urls

Posted: Mon Apr 02, 2007 6:12 pm
by Pierre M.
The instruction in the wiki about pretty URLs are known to work. But htaccess tuning is sensitive.

Try to set up a custom 500 error page with :
ErrorDocument 500 /path/to/your/static500.html
and try this test :
http://forum.cmsmadesimple.org/index.ph ... l#msg43943
Please tell us the results.

Pierre M.

Re: stupid problem with pretty urls

Posted: Mon Apr 02, 2007 7:28 pm
by newagekat
the subject line did say "stupid problem".

ok it was a dumb error on my part.  if this benefits anyone else, here's what I found out:
  • place .htaccess in root and add /directoryname/ next to RewriteBase
  • create custome error pages in root
  • if using extensions in the .htaccess file, your code should be:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /climbKili/

# 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/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]

ErrorDocument 404 /404.shtml
  • in config, use recomended settings, but be sure to have page extension match the extension you use in .htacess.  like this:

Code: Select all

#Extension to use if you're using mod_rewrite for pretty URLs.
$config['page_extension'] = '.html';
Once more, I bow to you geniuses.  my mistake.

Re: stupid problem with pretty urls

Posted: Mon Apr 02, 2007 8:22 pm
by piotrekkr
Hi. My friend tried to enable pretty urls in his paid hosting and there wasn't any problems. He did it like in installation instruction so I think that my apache localhost configuration is wrong.
Part of httpd.comf file that I think is connected with mod rewrite:

Code: Select all

.........

LoadModule rewrite_module modules/mod_rewrite.so

..........

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>
Any suggestion what could be wrong??

Re: stupid problem with pretty urls

Posted: Tue Apr 03, 2007 1:54 pm
by Pierre M.
Hello,
piotrekkr wrote: ...I think that my apache localhost configuration is wrong.
Part of httpd.comf file that I think is connected with mod rewrite:
...
Any suggestion what could be wrong??
Please read the sticky thread "how to ask question to get answers". If you don't describe your situation and your problem, it is almost impossible to help you.

Pierre M.

Re: stupid problem with pretty urls

Posted: Tue Apr 03, 2007 5:46 pm
by piotrekkr
I read it. I think that you didn't read all posts in this topic because I make this topic and describe my problem in first post. I write last post because I fought that something could be wrong with httpd.conf.

Re: stupid problem with pretty urls

Posted: Wed Apr 04, 2007 9:01 pm
by Pierre M.
Sorry, my mistake, I apoligize. I hadn't "linked" your new post with the one at the begining of the thread. I thought you'd just jumped in after the newagecat.
So, you are writing a module. Hu.. I don't know module programming. May be you can read Elijah's thread where he explains how to make a blog with a module and pretty URLs and read his code.

Pierre M.