0

I have a rewritemap with below like content -

    /sub1/sub2/  /content/sub1/sub2.html
    /sub3/sub4/  /content/sub3/sub4.html
    /sub5/  /content/sub5.html

    RewriteMap testuri dbm:conf/extra/testuri.map
    RewriteCond ${testuri:$1} !=""
    RewriteRule ^(.*)$ ${testuri:$1|/test} [PT,L]

Above URL works fine and it redirects source to target with pass through.

Now, my requirement is that if URI's are being accessing with html extension (for example, domain.com/sub1/sub2.html), then it should get redirect to page with 404 status code.

(1) Can this be achieved without modifying the current map file? Note: In my website, only the pages in dbm map file are the ones with no-html extension. All the pages are with .html extension. (2) All the pages that doesn't exist in dbm map are .HTML pages and should be redirected to 404 page when accessed with / (or without any extension) at the end?

Can someody help?

Regards

Vishnu
  • 7
  • 1

1 Answers1

0

Try putting this at the top of your rules:

 RewriteCond %{THE_REQUEST} \.html/?\sHTTP
 RewriteRule ^ - [R=404]
Dusan Bajic
  • 10,249
  • 3
  • 33
  • 43