[SOLVED] pretty urls mod_rewrite real slow

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.
Locked
MaKK0
Forum Members
Forum Members
Posts: 17
Joined: Thu Jun 05, 2008 7:59 am

[SOLVED] pretty urls mod_rewrite real slow

Post by MaKK0 »

Since I am working on a new template for my website I thought this is a good moment to go pro and enabling pretty urls by mod-rewrite for my own website. I have done it for multiple clients as well, so this shouldn't be that hard. I thought....

The problem is when I enable mod_rewrite the page loading is going really slow. When disabled the loading is going well.

Enabled
Disabled

The crazy thing is that I have a perfectly running CMSMS with pretty urls running at the same hosting provider (www.pcextreme.nl).

How am I going to be able enjoying nice and clean urls?


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

THINGS THAT MIGHT BE USEFUL

CMS is running in a subdirectory like this http://www.domain.tld/nl/

SYSTEM INFORMATION
PHP Effective Memory Limit (memory_limit): 32M
Maximum Execution Time (max_execution_time): 30

CONFIG FILE
#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'] = '.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;

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


.HTACCESS
  Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /nl/

  # 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
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+)$ index.php?page=$1 [QSA]


INSTALLED SOFTWARE
CMS Made Simple 1.4.1 "Spring Garden"

Installed Modules

CMSMailer 1.73.14
MenuManager 1.5.1
ModuleManager 1.2.1
News 2.8.2
nuSOAP 1.0.1
Search 1.5.1
ThemeManager 1.0.8
TinyMCE 2.4.5
RSS 1.1
FileManager 0.4.1
Printing 0.2.5
TruetypeText 2.0.2
FormBuilder 0.5.5
Captcha 0.3.1
Last edited by MaKK0 on Sun Dec 28, 2008 7:26 pm, edited 1 time in total.
Pierre M.

Re: pretty urls mod_rewrite real slow

Post by Pierre M. »

Hello,
MaKK0 wrote: $config['page_extension'] = '.html';

# 301 Redirect all requests that don't contain a dot or trailing slash to include a trailing slash
RewriteCond...
Know what you want : '.html' or a trailing slash.
MaKK0 wrote: CMS Made Simple 1.4.1 "Spring Garden"

Installed Modules
What about using the latest official stable package ?
Check your module list for unused uncore modules and deactivate them.

BTW, are your numbers reproducible for each request ? what do they become with 1.5.1 ?

Pierre M.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: pretty urls mod_rewrite real slow

Post by Dr.CSS »

The other thing is your RewriteBase /nl/ it should be RewriteBase /nl ...
mannerv
Forum Members
Forum Members
Posts: 49
Joined: Wed May 28, 2008 1:02 pm

Re: pretty urls mod_rewrite real slow

Post by mannerv »

This could be related:

"Unbelievably mod_rewrite provides URL manipulations in per-directory context, i.e., within .htaccess files, although these are reached a very long time after the URLs have been translated to filenames. It has to be this way because .htaccess files live in the filesystem, so processing has already reached this stage. In other words: According to the API phases at this time it is too late for any URL manipulations. To overcome this chicken and egg problem mod_rewrite uses a trick: When you manipulate a URL/filename in per-directory context mod_rewrite first rewrites the filename back to its corresponding URL (which is usually impossible, but see the RewriteBase directive below for the trick to achieve this) and then initiates a new internal sub-request with the new URL. This restarts processing of the API phases.

Again mod_rewrite tries hard to make this complicated step totally transparent to the user, but you should remember here: While URL manipulations in per-server context are really fast and efficient, per-directory rewrites are slow and inefficient due to this chicken and egg problem." (emphasis mine)

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
MaKK0
Forum Members
Forum Members
Posts: 17
Joined: Thu Jun 05, 2008 7:59 am

Re: pretty urls mod_rewrite real slow

Post by MaKK0 »

Wow, great stuff!

Changed RewriteBase /nl/ to RewriteBase /nl and now it is working just fine! Thanks!

After removing the /

Thanks for making me aware of v1.5.1. Will upgrade soon!
Locked

Return to “CMSMS Core”