Page 1 of 1

Home without index.php

Posted: Mon Apr 15, 2024 7:14 pm
by Diniz
I just started with CMSMS. How can I remove index.php from the home URL? This is my root:

https://localhost/cmsms/

I followed the instructions on this page to get it done but without result:

https://docs.cmsmadesimple.org/configuration/pretty-url

The only thing I did else so far after installation is setting up SSL. So this is my config.php:

Code: Select all

$config['dbms'] = 'mysqli';
$config['db_hostname'] = 'localhost';
$config['db_username'] = 'root';
$config['db_password'] = 'pass';
$config['db_name'] = 'cmsms';
$config['db_prefix'] = 'cms_';
$config['timezone'] = 'Europe/Amsterdam';

$config['root_url'] = 'https://localhost/cmsms';
$config['admin_url'] = 'https://localhost/cmsms/admin';

$config['url_rewriting'] = 'mod_rewrite';
And this my .htaccess:

Code: Select all

<IfModule rewrite_module>
 
RewriteEngine on
# CMSMS installation is in subdirectory
  RewriteBase /cmsms

# force https
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# remove 'www' from REQUEST_URI
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

# Rewrites URLs in the form of /parent/child/grandchild 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]

</IfModule>
When I enter this URL I get a blank page. When I enter https://localhost/cmsms/index.php this page show up:

Image

I assume this is the home page? What do I need to do more to get it done?

Re: Home without index.php

Posted: Mon Apr 15, 2024 7:58 pm
by DIGI3
It looks like you've done it correctly, is there any chance your DirectoryIndex isn't configured correctly, and/or you have an index.html or similar file in your site's directory?

Re: Home without index.php

Posted: Mon Apr 15, 2024 8:51 pm
by Diniz
DIGI3 wrote: Mon Apr 15, 2024 7:58 pm It looks like you've done it correctly, is there any chance your DirectoryIndex isn't configured correctly, and/or you have an index.html or similar file in your site's directory?
Yes that's it! There was an index.html present. After removing it is working now, but also index.php still is. How can I rewrite https://localhost/cmsms/index.php also correctly to https://localhost/cmsms/?

I tried inserting this and some similar rules:

Code: Select all

# Redirect requests for /index.php to the root directory
  RewriteCond %{THE_REQUEST} \s/index\.php\s [NC]
  RewriteRule ^index\.php$ /cmsms/ [R=301,L]
This is my entire htaccess file now:

Code: Select all

<IfModule rewrite_module>
 
RewriteEngine on
# CMSMS installation is in subdirectory
  RewriteBase /cmsms

# force https
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# remove 'www' from REQUEST_URI
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

# Redirect requests for /index.php to the root directory
  RewriteCond %{THE_REQUEST} \s/index\.php\s [NC]
  RewriteRule ^index\.php$ /cmsms/ [R=301,L]
  
# Rewrites URLs in the form of /parent/child/grandchild 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]

Re: Home without index.php

Posted: Mon Apr 15, 2024 10:03 pm
by DIGI3
I'm not sure that would be possible, or a good idea if it was. You'll likely just end up in some infinite loop.

Re: Home without index.php

Posted: Tue Apr 16, 2024 7:23 pm
by Diniz
This below works. Thanks for your help!

Code: Select all

<IfModule mod_rewrite.c>
 
  RewriteEngine on

# CMSMS installation is in subdirectory
  RewriteBase /cmsms

# force https
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# remove 'www' from REQUEST_URI
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

# Redirect /index.php to the root directory
  RewriteCond %{THE_REQUEST} ^GET\ /cmsms/index\.php[\s?]
  RewriteRule ^index\.php$ /cmsms/ [R=301,L]

# Rewrites URLs in the form of /parent/child/grandchild 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]

</IfModule>