Apache 简单的不经意重定向不起作用?

Apache 简单的不经意重定向不起作用?,apache,.htaccess,mod-rewrite,redirect,url-rewriting,Apache,.htaccess,Mod Rewrite,Redirect,Url Rewriting,我的目标是通过以下方式将对mydomain.com/foo的访问重定向到mydomain.com/bar.html: 1-用户无法分辨hs重定向到何处 2-url非常漂亮,既不包含文件名、扩展名也不包含参数 以下是我在该问题上发现的一系列示例,我的.htaccess文件的内容如下: Options +FollowSymLinks RewriteEngine On RewriteRule ^/foo$ /bar.html [PT] 这是行不通的。对mydomain.com/foo的请

我的目标是通过以下方式将对mydomain.com/foo的访问重定向到mydomain.com/bar.html: 1-用户无法分辨hs重定向到何处 2-url非常漂亮,既不包含文件名、扩展名也不包含参数

以下是我在该问题上发现的一系列示例,我的.htaccess文件的内容如下:

Options +FollowSymLinks

RewriteEngine  On
RewriteRule    ^/foo$  /bar.html [PT]
这是行不通的。对mydomain.com/foo的请求给出404错误

虽然我希望能简短地解释一下为什么上面的例子不起作用,但我更希望能得到关于使用重写引擎的正确教程的指导;我发现的所有标签似乎都假设读者已经了解了各个方面,比如语法和它的意思,或者标签([PT]、[R]、[L]…?)

提前谢谢

试试这个:

Options +FollowSymLinks

RewriteEngine  On
RewriteRule    ^/?foo$  /bar.html [PT]
让我知道它是否有效

请尝试以下代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^foo/?$ /bar.html [L,NC]

它不起作用。发生的情况是,/foo被重定向到foo.html,/bar被重定向到/bar.html,而像/tup这样的不存在的文件名可以将重写日志放在这里吗?与Death建议的行为相同。直接输入时会发生什么:
http://domain.com/bar.html
在您的浏览器中?