We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16902
    • 7 Posts
    Modx 2.2.4 on Ubuntu-server:
    http://servername.se/domain.se/ (= http://bit-utv.se/bahai.se/)

    Modx (test sites) roots in:
    servername.se:/var/www/domain.se (= bit-utv.se:/var/www/bahai.se/)
    and also in:
    servername.se:/var/www/sub.domain.se (= bit-utv.se:/var/www/new.bahai.se/)

    After (too) many trials I succeeded to get the .htaccess files to work (!), however not really corresponding to the samples from Modx Wiki/Tutorials or this Forum:
    https://forums.modx.com/thread/?thread=5185&page=1
    https://forums.modx.com/thread/75222/friendly-urls-always-404-for-me-in-revo-2-2-0-pl2#dis-post-416877
    (and some other threads)

    My .htaccess file:
    RewriteEngine On
    RewriteBase /bahai.se
    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]
    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    #RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^bit-utv\.se/bahai\.se [NC]
    #RewriteRule ^(.*)$ http://bit-utv.se/bahai.se/$1 [R=301,L]
    
    # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
    # https://www.domain.com when your cert only allows https://secure.domain.com
    #RewriteCond %{SERVER_PORT} !^443
    #RewriteRule (.*) https://www.bit-utv.se/bahai.se/$1 [R=301,L]
    # Exclude /assets and /manager directories from rewrite rules
    RewriteRule ^(manager|assets) - [L]
    
    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    # Additional Settings Follow
    BrowserMatch "MSIE" brokenvary=1
    BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
    BrowserMatch "Opera" !brokenvary
    SetEnvIf brokenvary 1 force-no-vary
    

    (I guess not all lines are mandatory, but for safety's.)

    1. It works, but why has this line to be commented/disabled:
    #RewriteRule ^(.*)$ http://bit-utv.se/bahai.se/$1 [R=301,L]

    - or change it to enable? It works on another server, but I have no access to that.

    2. Now I would like to transfer this to default file in apache2 and remove the .htaccess files. This should speed up the process a little as the server does not have to search for .htaccess files in all directories - according to
    http://httpd.apache.org/docs/current/howto/htaccess.html

    So I tried all possible combinations in these two files, however only resulting in 404 or 500 server errors:
    /etc/apache2/sites-available/default
    /etc/apache2/httpd.conf

    (View attachment.)
    Thanks for any guiding.
    Regards Leif Hjerpe
    PS
    Apache2 configured:
    /etc/apache2/apache2.conf
    LoadModule rewrite_module modules/mod_rewrite.so [ed. note: leif.hjerpe last edited this post 14 years ago.]