... h1. Apache mod_rewrite .htaccess Solutions for MODx MODx supports Friendly URLs via this .htaccess file. You must serve web pages via Apache with mod_rewrite to use this functionality, and you must change the file name from ht.access to .htaccess. Additional tweaks and environment specific additions follow the default template below: {code:none} # For full documentation and other suggested options, please see # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions Options +FollowSymlinks RewriteEngine On RewriteBase / # Fix Apache internal dummy connections from breaking [(site_url)] cache RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC] RewriteRule .* - [F,L] # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^example\.com [NC] RewriteRule (.*) http://example.com/$1 [R=301,L] # For Friendly URLs RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] # Reduce server overhead by enabling output compression if supported. #php_flag zlib.output_compression On #php_value zlib.output_compression_level 5 {code} {tip} If Windows IIS serves your pages, you're not left out of the Friendly URLs party, but optimal solutions do require a commercial IIS add on. For more information, see the [SEO Friendly URLs with IIS|http://modxcms.com/forums/index.php/topic,10915.0.html] page in the MODx forums. For other web servers such as Zeus or lighttpd, see our [General Requirements|http://modxcms.com/learn/general-requirements.html] page under supported web servers. {tip} h2. Common Edits to the Default Template Make sure RewriteBase points to the directory where you installed MODx. E.g., "/modx" if your installation is in a "modx" subdirectory: {code:none} RewriteBase /modx {code} Note in the last block of directives the gzip compression was left commented out since this can potentially cause issues in some environemnts. For a faster webserver experience, ucomment the last two lines as follows: {code:none} # Reduce server overhead by enabling output compression if supported. php_flag zlib.output_compression On php_value zlib.output_compression_level 5 {code} You may also want to make your URLs non-case-sensitive by adding a NC directive to the directive in the "For Friendly URLs" part: {code:none} RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC] {code} If you prefer your website to always add the "www." part to always show "www.example.com" URLs, then the section below should be changed as follows: {code:none} RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule (.*) http://www.example.com/$1 [R=301,L] {code} h2. Session Handling If you are deployed in an environment that has problems with aggressive garbage collection, as evidenced by unexpected and frequent logouts from the manager, then you can adjust the location of the sessions to remove them from the default and shared global tmp/session location: {code:none} php_value session.save_path /path/to/your/web/content/sessions/ php_value session.gc_maxlifetime 28800 {code} h2. Register Globals
|
... To verify that this option has been set to OFF, open the Manager and choose Reports \-> System Info and then click the phpinfo() link. Do a Find on Page for "register_globals". The Local Value should be OFF. If the Master Value is OFF then you do not need this directive here. IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS: Your server does not allow PHP directives to be set via .htaccess. In that case you must make this change in your php.ini file instead. If you are using a commercial web host, contact the administrators for assistance in doing this. Not all servers allow local php.ini files, and they should include all PHP configurations (not just this one), or you will effectively reset everything to PHP defaults. Consult www.php.net for more detailed information about setting PHP directives. {code:none} # Turn off register_globals because I have a lazy webhost that doesn't care about security php_flag register_globals Off {code} h2. Solving Internet Explorer Woes If htc files are being used on your site, some servers may serve this with the incorrect mime type. The following can be added to resolve this. The following is critical for MS Windows XP SP2 surfers: {code:none} # Fix .htc mime type for Internet Explorer AddType text/x-component .htc {code} The following directives stop screen flicker in IE on CSS rollovers. If needed, un-comment the following rules. When they're in place, you may have to do a force-refresh in order to see changes in your designs. {code:none} # Fix screen flicker for images in Internet Explorer ExpiresActive On ExpiresByType image/gif A2592000 ExpiresByType image/jpeg A2592000 ExpiresByType image/png A2592000 BrowserMatch "MSIE" brokenvary=1 BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1 BrowserMatch "Opera" !brokenvary SetEnvIf brokenvary 1 force-no-vary {code}
|