Page 2 of 2

Re: Pretty URL - mod_rewrite gives 404

Posted: Mon Dec 07, 2009 2:36 pm
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

Re: Pretty URL - mod_rewrite gives 404

Posted: Mon Dec 07, 2009 10:27 pm
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.

Re: Pretty URL - mod_rewrite gives 404

Posted: Tue Dec 08, 2009 7:09 am
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
*}

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Jan 22, 2010 10:01 pm
by Dr.CSS
If you have cmsms in a subfolder you need to have that .htaccess in that folder not the root...

Re: Pretty URL - mod_rewrite gives 404

Posted: Fri Jan 22, 2010 11:31 pm
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