【发布时间】:2021-04-02 22:31:56
【问题描述】:
我想在我的网站上做这个映射
xyz.html -> on /xyz
abc.html -> on /abc
index.html -> on /
我在我的 .htaccess 文件中写了这些规则
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !^$ !.*\.html$ %{REQUEST_FILENAME}.html [L]
但我有一些问题。
- 404 错误不再起作用。如果我浏览 /hello 它给了我内部服务器错误
- 如果我浏览到 /xyz.html -> /xyz(SEO 友好),我想要重定向
想要的行动:
/ -> serve index.html
/abc -> serve abc.html
/abc.html -> redirect to /abc
/123.html -> throws 404
/123/ -> throws 404 (now throws 500)
我该怎么做?提前谢谢你
【问题讨论】:
标签: apache redirect mod-rewrite url-rewriting friendly-url