Mobile app version of vmapp.org
Login or Join
Courtney195

: .htaccess errordocument 404 for .htm and .html My .htaccess is displayed below. It catches example.com/abcnonsense and sends it to my error page - 404error.htm. But fails to catch example.com/abcnonsense.htm

@Courtney195

Posted in: #Htaccess #ModRewrite

My .htaccess is displayed below.

It catches example.com/abcnonsense and sends it to my error page - 404error.htm.

But fails to catch example.com/abcnonsense.htm or example.com/abcnonsense.html.

In these cases it redirects to my home page.

Can anyone see where I am going wrong?

ErrorDocument 404 /404error.htm

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^myexample.com
RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^(.*)$ www.myexample.com/ [R=301,L]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI} [R=301,L]

RewriteCond %{DOCUMENT_ROOT}/index.html -f
RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^$ /index.html [NC,L]

RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^index.html$ / [NC,R,L]

RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^index.htm$ / [NC,R,L]

RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^$ /index.htm

RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteRule ^(.*.x?h?t?ml?)$ /cgi-bin/cms.cgi?a=pg&p=%{REQUEST_URI}&%{QUERY_STRING} [NC,L]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Courtney195

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

RewriteRule ^(.*.x?h?t?ml?)$ /cgi-bin/cms.cgi?a=pg&p=%{REQUEST_URI}&%{QUERY_STRING} [NC,L]



Because the very last line rewrites all .htm and .html requests to your /cgi-bin/cms.cgi script. Any 404's that result from .htm or .html requests would therefore need to be managed by this script. In other words, your CMS needs to manage the 404, not Apache.

EDIT: Unless... your CMS only works on .htm or .html files that physically exist on the filesystem? (Although I doubt this.)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme