[英]Rewrite rules for apache
Given this link: localhost/app/forms/enroll.php. 给定此链接:localhost / app / forms / enroll.php。 I want it to render when i access /register.
我希望它在我访问/注册时呈现。
For example: localhost/register will display localhost/app/forms/enroll.php 例如:localhost / register将显示localhost / app / forms / enroll.php
so basically I have this code: 所以基本上我有这段代码:
RewriteEngine On
RewriteBase /
RewriteRule register app/forms/enroll.php
In my code I have a call to localhost/enroll.php which i would want to redirect to /app/enroll.php but then I want to display the link (localhost/register) again. 在我的代码中,我有一个对localhost / enroll.php的调用,我想将其重定向到/app/enroll.php,但随后我想再次显示链接(localhost / register)。
So i need to call back again the RewriteRule i made above. 因此,我需要再次调用上面创建的RewriteRule。
adding this rule doesn't work 添加此规则不起作用
RewriteRule enroll.php register [R]
also this one 还有这个
RewriteRule enroll.php app/forms/enroll.php [C]
RewriteRule app/forms/enroll.php register
note: I need a workaround with this instead of having to change the links in the code. 注意:我需要一种解决方法,而不必更改代码中的链接。 :)
:)
If I understood right, you don't have to redirect several times. 如果我理解正确,则不必多次重定向。 Just map silently the first time, like this:
只需在第一时间静默映射,如下所示:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !enroll.php [NC]
RewriteRule ^register/?$ app/forms/enroll.php [L]
It will redirect silently 它将静默重定向
http://localhost/register
(This URL is always shown in the browser) http://localhost/register
(此URL始终显示在浏览器中)
To: 至:
http://localhost/app/forms/enroll.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.