Page 1 of 2

Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 3:01 pm
by nilson
Hello,
on my site pretty URLs are working with internal mode. My cms_root/config.php reads

Code: Select all

$config['url_rewriting'] = 'internal';
$config['page_extension'] = '.html';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
Now I want to get rid of the index.php in my Browser URL. When changing my config.php to

Code: Select all

$config['url_rewriting'] = 'mod_rewrite';
the internal URLs get rewritten to

Code: Select all

http://www.my-domain.com/cms/concept.html
but are not available under this URL (Error 404). I can only access my subpages when adding index.php by hand, like

Code: Select all

http://www.my-domain.com/cms/index.php/concept.html
In cms_root/.htaccess I got the following

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
# RewriteCond %{REQUEST_URI} !/$
# RewriteCond %{REQUEST_URI} !\.
# RewriteCond %{REQUEST_METHOD} !POST$
# 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
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).html$ index.php?page=$1 [QSA]
What would I have to do in order to refer to my domain name instead of the ip address?

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 4:38 pm
by Russ
I use the following and it works on Apache on Mac / Linux

Code: Select all

$config['url_rewriting'] = 'mod_rewrite';
$config['page_extension'] = '/';
$config['use_hierarchy'] = true;
$config['query_var'] = 'page';
.htaccess, looks OK but try commenting out

Code: Select all

"RewriteBase /" 
Hope this helps?

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:10 pm
by Rolf
If your website is in a subfolder, you need in this case:

Code: Select all

RewriteBase /cms
®olf

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:16 pm
by nilson
Thanks Rolf,
unfortunately no success with

RewriteBase /cms

Maybe it´s important that I have defined an alias in the apache config that points /cms to the most up-to-date installation of cmsms 1.6.6)

Code: Select all

Alias /cms "/srv/www/cms_cofis/current/"
<Directory "/srv/www/cms_cofis/current/">
..
</Directory>
Thanks for any suggestions,
nilson

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:25 pm
by Rolf
Got a link? (PM)

®

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:36 pm
by Rolf
Nilson,
Thanks for the link.
Can you please put your system information here.
And can you turn on the mod_rewrite so I can see it myself
®

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:43 pm
by nilson
Rolf,
mod_rewrite is enabled again.
Not sure what you mean with system info. The server runs on Debian Lenny

Code: Select all

myhost:/var/www/cms_cofis/current# apache2ctl status
Apache Server Status for localhost

Server Version: Apache/2.2.11 (Debian) DAV/2 mod_fastcgi/2.4.6 mod_python/3.3.1
    Python/2.5.4
Server Built: Mar 31 2009 19:14:53
and CMSMS 1.6.6

Do you need anything more from config.php?

Nils

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:48 pm
by Rolf
With System Information I mean:
Admin >> Site Admin >> System Information >> View Text Report (suitable for copying into forum posts)

®

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:50 pm
by nilson
Ups, here we go:

Code: Select all

----------------------------------------------

Cms Version: [b]1.6.6[/b]

Installed Modules:

    * nuSOAP: [b]1.0.1[/b]
    * CGExtensions: [b]1.8[/b]
    * htmlExport: [b]0.6.2.2b[/b]
    * Album: [b]0.9.3[/b]
    * CMSMailer: [b]1.73.14[/b]
    * FileManager: [b]1.0.1[/b]
    * MenuManager: [b]1.6.2[/b]
    * ModuleManager: [b]1.3.1[/b]
    * News: [b]2.10.3[/b]
    * Printing: [b]1.0.4[/b]
    * Search: [b]1.6.1[/b]
    * ThemeManager: [b]1.1.1[/b]
    * TinyMCE: [b]2.5.5[/b]


Config Information:

    * php_memory_limit: [b][/b]
    * process_whole_template: [b]false[/b]
    * max_upload_size: [b]2000000[/b]
    * default_upload_permission: [b]644[/b]
    * assume_mod_rewrite: [b]true[/b]
    * page_extension: [b].html[/b]
    * internal_pretty_urls: [b]false[/b]
    * use_hierarchy: [b]true[/b]


Php Information:

    * phpversion: [b]5.2.6-3[/b]
    * md5_function: [b]On[/b] (True)
    * gd_version: [b]2[/b]
    * tempnam_function: [b]On[/b] (True)
    * magic_quotes_runtime: [b]Off[/b] (False)
    * memory_limit: [b]128M[/b]
    * max_execution_time: [b]30[/b]
    * safe_mode: [b]Off[/b] (False)
    * session_save_path: [b]/var/lib/php5[/b] (1733)
    * session.use_cookies: [b]On[/b] (True)


Server Information:

    * Server Api: [b]apache2handler[/b]
    * Server Db Type: [b]PostgreSQL (postgres7)[/b]
    * Server Db Version: [b]8.3.5[/b]


----------------------------------------------

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:54 pm
by Rolf
Okay thx.

What Server Operating System (server_os) do you use? The copy funtion leaves that one out...

®

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 5:56 pm
by nilson
Debian Lenny with

Code: Select all

~# apache2ctl status
Apache Server Status for localhost

Server Version: Apache/2.2.11 (Debian) DAV/2 mod_fastcgi/2.4.6 mod_python/3.3.1
    Python/2.5.4
Server Built: Mar 31 2009 19:14:53

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 6:14 pm
by Rolf
nilson,

I'm afraid this topic is going beyond my knowledge...  :-\
Technical requirements

        * One of these operating systems:
              o Linux/Unix
              o Windows 2000/XP/Vista/Me/2003 (not recommended unless you master it)
              o Mac OS X

        * One of these webservers:
              o Apache 1.3
              o Apache 2
              o IIS 5+
              o LightTPD 1.4+
( http://wiki.cmsmadesimple.org/index.php ... quirements )

It might be possible your server configuration just isn't fit for mod_rewrite, but...  :-\

Perhaps somebody else has a clue?? Russ?

®olf

ps. you can switch mod_rewrite to internal again  ;)

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Dec 04, 2009 6:31 pm
by nilson
Rolf,
thanks so far.

@all: What would be the relevant lines in the apache.con? I got

Code: Select all

<IfModule mod_rewrite.c>
	RewriteEngine on
</IfModule>
at the end of the file

and mod_rewrite enabled via symlink in

Code: Select all

ls -l /etc/apache/mods-enabled
...
rewrite.conf -> ../mods-available/rewrite.load
...
and

Code: Select all

/usr/lib/apache2/modules/mod_rewrite.so
does exist.

nilson

Re: Pretty URL - mod_rewrite gives 404

Posted: Sat Dec 05, 2009 7:09 am
by Golf Gti
Are you sure your host has mod_rewrite enabled?

Some servers will tell you that you have mod_rewrite enable in the phpinfo file.

Create a blank page and call it info.php
Place this

Code: Select all

<? phpinfo(); ?>
and save file to your web server.
Or create a user defined tag and call it phpinfo with

Code: Select all

phpinfo();
and place on a page

Open file and search for mod_rewrite alternatively you will find it under the apache heading; loaded modules.
(note I'm using two hosts with mod_rewrite currently working, one has it listed in the phpinfo, one does not)

I for some reason think the internal pretty url works even if no mod_rewrite exsists. (correct me if Im wrong)

Re: Pretty URL - mod_rewrite gives 404

Posted: Sat Dec 05, 2009 9:03 am
by Russ
Sorry, about the '#RewriteBase /' red herring, I'd completely missed the sub directory. However, you could try removing it and pointing the domain/path in the httpd-vhosts.conf to the subdirectories (cms) root? This is what I do on a Mac which is Debian enough for me ;-)

Secondly in .htaccess I'd add above (RewriteEngine On), if it is not already there.

Code: Select all

Options +FollowSymLinks
I only glanced at the recent posts, but I presume mod_rewrite is running and there are no startup errors for the apache server??