【发布时间】:2023-03-11 08:43:01
【问题描述】:
所以我已经配置了我的 .htaccess 文件,这样当我加载网页 (http://example.com/about) 时,它会透明地将其重定向到 http://example.com/about.html,但是,我希望它现在是能够做到(http://example.com/about/contact),然后让它透明地重定向到http://example.com/about/contact.html。我想理想情况下它会完全忽略 URL 的“/about/”部分,只使用联系人部分。
这是我现在正在使用的:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
【问题讨论】:
标签: regex apache .htaccess mod-rewrite