Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在重定向/重写方面很糟糕。我在网站的特定子目录树中有许多 .shtml 文件,我想要 301 到 .html。所有其他 .shtml 文件都应保留。使用 Apache,RewriteEngine 已打开。
具体来说,将www.domain.com/homes/cityname/file.shtml许多城市和文件更改为 .html。homes子目录是不变的。
www.domain.com/homes/cityname/file.shtml
homes
www.domain.com/status.shtml保持原状,等等。
www.domain.com/status.shtml
尝试:
RedirectMatch 301 ^/homes/(.*)\.shtml /homes/$1.html
如果您更愿意使用 mod_rewrite 而不是 mod_alias:
RewriteRule ^homes/(.*)\.shtml /homes/$1.html [R=301]