how return 404 error
url characters after second /
htaccess.
e.g1:
http://www.example.com/blah-blah/
not redirect (no characters after 2th /
)
e.g2:
http://www.example.com/blah-blah/blah-blah
redirect 404
e.g3:
http://www.example.com/blah-blah/blah-blah/
redirect 404
e.g4:
http://www.example.com/blah-blah/blah-blah/blah-blah
redirect 404
e.g5:
http://www.example.com/blah-blah/blah-blah/blah-blah/
redirect 404
i tried not works e.g3 & e.g5 (urls ending slash):
errordocument 404 /404 rewritebase / rewriterule ^[^/]+/.+ - [r=404,l]
in order redirect request if there characters after second slash, need rewrite rule
errordocument 404 /404 rewritebase / rewriterule .*/.+ - [r=404,l]
ps : when you're using dash after regexp, says pass matches filesystem.
edit : pattern /.*/.+ matches next example, forgot rewritebase directive, need remove first slash in pattern (i edit rewriterule before)
- /blah-blah/ => not match
- /blah-blah/blah-blah => match
- /blah-blah/blah-blah/ => match
- /blah-blah/blah-blah/blah-blah/ => match
ps : can use tools, check if rewrite works rewrite-rule-tester
Comments
Post a Comment