URLs and Redirection

Permalink
Once again I've hit the same old problem I always face... URLs and Redirection.
I'm Running 8.4.2.
I add the .htaccess file with code as below:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
I check the box for 'Remove index.php from URLs' and add the domain to Canonical URL field.

This breaks the site with an internal server error.

If I remove the .htaccess file the home page works, but other links show 'not found error'.

Can anyone confirm the exact method that works please?

deanhawthornthwaite
View Replies:
madesimplemedia replied on at Permalink Reply
madesimplemedia
What server do you have, Apache, NGINX etc?

Seems like the default C5 redirect isn't quite right for your server.
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Hi madesimplemedia,

Just found out, my server is Apache running on CloudLinux.
Is there a procedure for this type of server please?
madesimplemedia replied on at Permalink Reply
madesimplemedia
hmmm, I'm surprised it doesn't work.

Maybe try:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Thanks for the code change.
It worked for page navigation, however when I tried to delete a page from the sitemap i got an error saying not allowed.
madesimplemedia replied on at Permalink Reply
madesimplemedia
What did it say "Access Denied"?
Are you logged in as the super user?
If you refresh the page and try again does it work?
deanhawthornthwaite replied on at Permalink Reply 1 Attachment
deanhawthornthwaite
here's the weird thing.

with the htaccess code in place but not selected in the CMS under 'Remove index.php from URLs' it works fine. The pages can be found and deleted.
If Remove index.php is ticked it gives the error 'access denied' as shown in attached screen shot.
weyboat replied on at Permalink Reply
weyboat
If your server is running mod_security in the back end, try switching it off.
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Hi weyboat,

Is it wise to turn off mod security or are you just suggesting to find a fault?
madesimplemedia replied on at Permalink Reply
madesimplemedia
What happens if you remove the domain name fromt he canonical field?
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Removing the domain from canonical makes no difference, however i have discovered something more strange.

With the htaccess file and code you gave me in place, but without activating pretty URL's in the CMS, it removed index.php anyhow and I can delete pages too.
madesimplemedia replied on at Permalink Reply
madesimplemedia
So is everything ok now?
Steevb replied on at Permalink Reply
Steevb
Do you have an SSL certificate?

Do you redirect www to non www?
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
no certificate and not using www at all. Thanks.