【发布时间】:2017-05-15 15:56:14
【问题描述】:
这似乎应该是一件相对容易的事情,但我想不通。我正在尝试使用 htaccess 文件进行重定向: http://www.example.com/page(或http://example.com/page) 到 http://www.example.com/page.htm
这是一个非常特殊的情况,我不需要任何通配符或任何将 /anything 重定向到 /anything.htm - 只需要特别是“/page”到“/page.htm”
我做了一些搜索,发现了相反的情况(从 /page.htm 到 /page)和其他使用通配符的情况,但找不到像这样的一个非常具体的重定向。提前致谢。
编辑:我遇到了麻烦,因为 htaccess 文件中的另一条规则似乎在干扰:
RewriteCond %{REQUEST_URI} !^/(admin|css|js|images|img|handouts|amp_sections|amp_sections\/handouts)($|/)
RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|js|png|bmp|ico|css|shtml|dat|xml|csv|txt|rtf|doc|docx|xls|xlsx|ppt|pptx)$
RewriteCond %{REQUEST_URI} !301
RewriteCond %{REQUEST_URI} !401
RewriteCond %{REQUEST_URI} !403
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /base.php?page=$1 [P,QSA]
因此,当我将页面重定向规则设置为 page.htm 时,输入 example.com/page 会将我带到 http://www.example.com/page.htm?page=page,这显然不是预期的行为。我不知何故需要让“新”规则优先于其他规则。
【问题讨论】: