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
 
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.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
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?
deanhawthornthwaite replied on at Permalink Reply 1 Attachment
deanhawthornthwaite
I wanted to experiment on another site before I made any more comments to make sure it wasn't a one-off.
On a different site, I added your code to htaccess and turned on remove index.php from CMS.
Front end of site works fine with index.php removed.
Back end works too, except if i click on the dashboard link top right i get a blank column (shown in attachment) and i can't delete a page (Access Denied Error).
There may be other errors but its not an exhaustive test.
madesimplemedia replied on at Permalink Reply
madesimplemedia
Are you logged in as the super admin? If not, you may not have permissions to delete a page.
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Yes I'm super admin on both sites.
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.
radeff replied on at Permalink Reply
radeff
so your testing that on a local machine eg localhost?

that's maybe the cause, apache is sometime pretty hard to fine tune, maybe it has nothing to do with c5 but is caused by a wrong config in apache or a missing module

check your /var/log/apache2 it may help
deanhawthornthwaite replied on at Permalink Reply
deanhawthornthwaite
Its not a local machine its on the web on my web hosting provider.
not sure what to do with your suggestion about /var/log/apache2 thats above my knowledge.