2013-01-23 147 views
0

鑑於此鏈接:localhost/app/forms/enroll.php。 我希望它在我訪問/註冊時呈現。apache的重寫規則

例如:本地主機/寄存器將顯示本地主機/應用/形式/ enroll.php

所以基本上我有這樣的代碼:

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

在我的代碼有一個呼叫到本地主機/登記.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 

注:我需要一種解決方法,而不必更改代碼的鏈接。 :)

回答

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

+0

像魅力一樣工作!謝謝! – Tom