Page 1 of 1

Pretty urls not working for me

Posted: Tue Oct 11, 2016 1:49 pm
by rubick
I have a functioning site with cmsms and I'm trying to enable pretty urls. I'm following the instructions on this page https://docs.cmsmadesimple.org/configuration/pretty-url
but it's not working. I can get to the landing page, but each nav link takes me to a 404 page not found.
If I manually enter http://www.mysite.com/index.php?page=mypage the page is found.

I'm using cmsms 2.1.5 on ubuntu 14.04, apache 2.4.7 and mysql 5.5.52

This is the conf file in sites-enabled

Code: Select all

<VirtualHost www.mysite.com:80>
        ServerName www.mysite.com
        DocumentRoot /var/www/cmsms
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        <Directory /var/www/cmsms/assets>
                Options FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>
        <Directory /var/www/cmsms/local_assets>
                Options FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>
</VirtualHost>
This is my .htaccess file

Code: Select all

ServerSignature Off
<IfModule rewrite_module>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
<Files ~ "\.htaccess">
  Order allow,deny
  Deny from all
</Files>
<Files ~ "\.ini$">
  Order allow,deny
  Deny from all
</Files>
<Files ~ "\.log$">
  Order allow,deny
  Deny from all
</Files>
<Files ~ "config\.php">
  Order allow,deny
  Deny from all
</Files>
<Files ~ "/lib/*php">
  Order allow,deny
  Deny from all
</Files>
RedirectMatch 403 ^/.*\.htaccess$
RedirectMatch 403 ^/.*\.log$
RedirectMatch 403 ^/.*\.ini$
RedirectMatch 403 ^/.*config\.php$
RedirectMatch 403 ^.*/doc/.*$
RedirectMatch 403 ^.*/lib/.*\.php$
RedirectMatch 403 ^.*/tmp/.*\.php$
RedirectMatch 403 ^.*/plugins/.*\.php$
RedirectMatch 403 ^.*/modules/.*\.php$
RedirectMatch 403 ^.*/uploads/.*\.php$
<IfModule mod_headers.c>
        # Disable Last-Modified for performance
        Header unset Last-Modified
        # Disable ETags
        Header unset ETag
        FileEtag None
        # For Security
        Header set X-Frame-Options "SAMEORIGIN"
</IfModule>
<IfModule deflate_module>
        AddOutputFilterByType DEFLATE text/html text/css text/plain text/html text/xml image/gif image/jpeg image/png image/ico text/javascript application/x-javascript application/javascript application/json application/pdf
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
# Set expires tags on various file types... so that the browser wont attempt to reload them.
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/ico "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType video/x-flv "access plus 1 year"
ExpiresByType application/pdf "access plus 1 year"
ExpiresByType application/x-shockwave-flash "access plus 1 year"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
        <IfModule mod_headers.c>
                # Setting cache control to public allows proxy servers to cache the items too.
                Header set Cache-Control "public"
        </IfModule>
</IfModule>
rewrite module is enabled as well as the others cited in htaccess.
$config['url_rewriting'] = 'mod_rewrite'; is in my config.
I've cleared the site cache several times without success.

Is there anything additional that needs to be done? After enabling pretty urls, there are a few options that appear in the content editor. I've tried to play with these as well, without success.

Re: Pretty urls not working for me

Posted: Tue Oct 11, 2016 3:33 pm
by velden
You should focus on apache and the .htaccess.
CMSMS is not involved yet actually unless you've changed the query parameter, but as you wrote 'index.php?page=mypage' does work it should be ok.

If your website's url has sub 'folders' in it it should be in the RewriteBase directive in the .htaccess (e.g. http://example.com/cmsms/mypage

Default .htaccess (docs/htaccess.txt) usually does the job for me.

Re: Pretty urls not working for me

Posted: Wed Oct 12, 2016 1:39 pm
by rubick
This apache webserver runs several virtual hosts. In the config for this virtual host, the docroot is /var/www/cmsms
That means in the htaccess file I should leave the ReWriteBase to / right?

I've tried it both ways, and neither work. I'm stumped.

Re: Pretty urls not working for me

Posted: Wed Oct 12, 2016 5:21 pm
by rubick
I managed to figure out what was going on.
Ubuntu doesn't allow htaccess files by default.
I added the following line to my sites-enabled config and now pretty urls are working.

Code: Select all

<Directory /var/www/cmsms>
       AllowOverride All
</Directory>