Pretty URL - mod_rewrite gives 404

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.
nilson
Forum Members
Forum Members
Posts: 15
Joined: Wed Apr 23, 2008 8:52 am

Re: Pretty URL - mod_rewrite gives 404

Post by nilson »

Alright,
after taking a break for the weekend  ;) ... I created the info.php and it says:

Code: Select all

apache2handler
Apache Version	Apache
Apache API Version	20051115
...
Virtual Server	Yes
Server Root	/etc/apache2
Loaded Modules	core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file
mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_dav mod_dav_fs mod_dir
mod_env mod_fastcgi mod_fcgid mod_mime mod_negotiation mod_php5 mod_python mod_setenvif mod_speling mod_status mod_suexec mod_rewrite
mod_rewrite seems to be enabled and loaded. What now?

edit:
@Russ: apache gives no startup errors when restarting and the error.log doesn´t say anything suspicious:

Code: Select all

[Mon Dec 07 15:55:34 2009] [notice] Graceful restart requested, doing restart
[Mon Dec 07 15:55:36 2009] [notice] FastCGI: process manager initialized (pid 20473)
[Mon Dec 07 15:55:36 2009] [notice] mod_python: Creating 8 session mutexes based on 150 max processes and 0 max threads.
[Mon Dec 07 15:55:36 2009] [notice] mod_python: using mutex_directory /tmp 
[Mon Dec 07 15:55:36 2009] [notice] Apache/2.2.11 (Debian) DAV/2 mod_fastcgi/2.4.6 mod_python/3.3.1 Python/2.5.4 configured -- resuming normal operations
nilson
Last edited by nilson on Mon Dec 07, 2009 3:09 pm, edited 1 time in total.
Golf Gti

Re: Pretty URL - mod_rewrite gives 404

Post by Golf Gti »

I guess to confirm that mod re-write is working

I would create a folder called "mod" in the root the web, create and "old" and "new" folder
Inside the old folder put index1.html with some text soo you know its the old page.
Inside the new folder put index.html so you know its the new page.

Then create an .htaccess file inside the folder "mod" with

Code: Select all

RewriteEngine On 
Redirect 301 /mod/old/index1.html http://www.siteurl.com/mod/new/index.html
navigate to http://www.siteurl.com/mod/old/index1.html
This should redirect you to the new page with url http://www.siteurl.com/mod/new/index.html

That to me confirms 100% mod_rewrite is working.
Another note, if you place bad code inside to .htaccess file it will break the mod_rewrite i noticed once.
So try with a basic htaccess file with just the rewrites you need.
User avatar
Rolf
Power Poster
Power Poster
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Contact:

Re: Pretty URL - mod_rewrite gives 404

Post by Rolf »

Hi nilson

I just noticed the following:

Your code out of the first post:

Code: Select all

# 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]
But the default .htaccess code 1.6.6 (found in the /doc folder as file htaccess.txt) is:

Code: Select all

# 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 ^(.+)$ index.php?page=$1 [QSA]
You see the difference (.html), perhaps...

®


{*
In order to use the right file!
Copy the htaccess.txt file out of the /doc folder to the root of the website and rename it into .htaccess
*}

{*
And don't forget to change: RewriteBase /cms
*}
Last edited by Rolf on Tue Dec 08, 2009 9:25 am, edited 1 time in total.
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Pretty URL - mod_rewrite gives 404

Post by Dr.CSS »

If you have cmsms in a subfolder you need to have that .htaccess in that folder not the root...
jbdough
New Member
New Member
Posts: 9
Joined: Sun Jan 10, 2010 8:28 am

Re: Pretty URL - mod_rewrite gives 404

Post by jbdough »

Dr.CSS wrote: If you have cmsms in a subfolder you need to have that .htaccess in that folder not the root...
right again Dr.CSS -

with the doc/htaccess.txt copied to /cmsms as .htaccess with
RewriteBase /cmsms

works like a charm.
One more thing to do, in config.php change

$config['root_url'] = 'http://domain.com/cmsms';
to
$config['root_url'] = 'http://domain.com';

then with root .htaccess -

Code: Select all

Options -Indexes
RewriteEngine On
RewriteOptions inherit

# if it's not a real file
RewriteCond %{SCRIPT_FILENAME} !-f
# rewrite to the subdirectory
RewriteRule !^cmsms(/?|/.+)$ /cmsms%{REQUEST_URI} [L]
all is good - I think ... :) - thank you
Last edited by jbdough on Sat Jan 23, 2010 3:39 pm, edited 1 time in total.
Locked

Return to “CMSMS Core”