user2089001
user2089001

Reputation: 23

.htaccess being ignored? Not redirecting like it's supposed to

Okay I'm trying to use Lando (landocms.com) and I'm trying to get the pretty urls option to work.

Basically by default Lando creates link like: domain.com/index.php/page. Supposedly, there is a way to remove the index.php so the links become: domain.com/page. I have created an .htaccess as directed, however it does not work.

Here is the .htaccess I am using:

<IfModule mod_rewrite.c>
  RewriteCond   %{REQUEST_FILENAME}   !-f 
  RewriteCond   %{REQUEST_FILENAME}   !-d 
  RewriteRule   ^(.*)$                index.php/$1  [L]
</IfModule>

I have tried alot of variations, /index.php/, index.php? and plenty more but none work. According to HostGator everything should be fine. Any thoughts? I think I'm going crazy haha.

Thanks!

Upvotes: 0

Views: 744

Answers (2)

Olaf Dietsche
Olaf Dietsche

Reputation: 74018

You want to remove the index.php part from any URL, but process the incoming, friendly URLs through index.php nevertheless

RewriteEngine On

# remove index.php and redirect client
RewriteCond %{ENV:REDIRECT_SEO} ^$
RewriteRule ^/?index.php/(.*) /$1 [R,L]

# process friendly URL
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule .+ /index.php/$0 [E=SEO:1,L]

The environment setting E=SEO:1 prevents an endless loop.

Upvotes: 0

Mike Rock&#233;tt
Mike Rock&#233;tt

Reputation: 9007

Rewriting for a CMS is a two-tier approach. First, you need to set your .htaccess (I have put a safer one here for you):

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php [QSA,L]

Then, LandoCMS allows you to remove the index.php from the generated addresses, by means of turning on the appropriate setting in the administration panel. See this link for more information.

If the .htaccess content I've given you doesn't work, then simply use the one that the CMS has given you.

Upvotes: 2

Related Questions