Home without index.php

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.
Post Reply
Diniz
New Member
New Member
Posts: 3
Joined: Mon Apr 15, 2024 6:08 pm

Home without index.php

Post 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?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1630
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Home without index.php

Post 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?
Not getting the answer you need? CMSMS support options
Diniz
New Member
New Member
Posts: 3
Joined: Mon Apr 15, 2024 6:08 pm

Re: Home without index.php

Post 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]
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1630
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Home without index.php

Post 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.
Not getting the answer you need? CMSMS support options
Diniz
New Member
New Member
Posts: 3
Joined: Mon Apr 15, 2024 6:08 pm

Re: Home without index.php

Post 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>
Post Reply

Return to “CMSMS Core”