0

鉴于此链接:localhost/app/forms/enroll.php。我希望它在我访问/注册时呈现。

例如:localhost/register 将显示 localhost/app/forms/enroll.php

所以基本上我有这个代码:

RewriteEngine On
RewriteBase /
RewriteRule register app/forms/enroll.php

在我的代码中,我调用了 localhost/enroll.php,我想将其重定向到 /app/enroll.php,但随后我想再次显示链接(localhost/register)。

所以我需要再次回调我上面所做的 RewriteRule。

添加此规则不起作用

RewriteRule enroll.php register [R]

还有这个

RewriteRule enroll.php app/forms/enroll.php [C]
RewriteRule app/forms/enroll.php register 

注意:我需要解决此问题,而不必更改代码中的链接。:)

4

1 回答 1

0

如果我理解正确,您不必多次重定向。第一次只需静默映射,如下所示:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}  !enroll.php         [NC]
RewriteRule ^register/?$  app/forms/enroll.php  [L]

它会默默地重定向

http://localhost/register (此 URL 始终显示在浏览器中)

到:

http://localhost/app/forms/enroll.php

于 2013-01-23T03:55:56.587 回答