开发者

.htaccess redirect 404 error to directory if it exists

开发者 https://www.devze.com 2022-12-27 13:30 出处:网络
Is there any way to make /name.html and /name/ work interoperably in the ev开发者_StackOverflow社区ent of a 404 error?

Is there any way to make /name.html and /name/ work interoperably in the ev开发者_StackOverflow社区ent of a 404 error?

For example, if the following fails: http://domain.com/name.html

Then it would attempt: http://domain.com/name/

And only go to a 404 page if that directory didn't exist? The reverse would be interesting too, going from dir to .html, and then finally to 404 on a double fail.


RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^([a-zA-Z0-9-]+)\.html$ $1/ [L]
0

精彩评论

暂无评论...
验证码 换一张
取 消