Modified htaccess with recommendations of SEO software. Can't get everything to work at the same time

40 Views Asked by At

I added some lines to my htaccess to fix a few SEO errors. These new lines caused other errors. Now I can't get everything to work properly at the same time.

I need two things. First, when a page is not found, I need the website to indicate a 404 error at 404-error.php (not index.php). Secondly, When I go to blog/ or blog/index.php the page does not work unless I remove other portions of the code. When I put that code back in the site won't show a 404 error when trying to access a page that doesn't exist. As of right now, if a page isn't found it forwards to blog/index.php

ErrorDocument 404 /404-error.php

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# Redirect index.php to root
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

RewriteBase /blog/

RewriteRule ^[^/]+/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
0

There are 0 best solutions below