URL重写规则显示带有文本的空白页面

时间:2015-01-03 16:55:07

标签: .htaccess url mod-rewrite url-rewriting rewrite

我正在学习如何重写网址并尝试在我的ubuntu服务器上执行此操作。我管理myselft以激活Allowoverride All并且我已经完成了工作。

我想更改此网址,例如:

http://serverismai/myapi/public/rest/navigate.php

我尝试这样做:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^home(.*)$ myapi/public/rest/curso/navigate.php/$1 [L]
</IfModule>

我尝试了各种解决方案,但这是我得到的最接近的解决方案。 url dosent会自动更改,但如果我插入http://serverismai/myapi/public/rest/home,我会看到一个空白页面,其中包含我的一些网站html(甚至不是页面的html,我正在尝试重写网址)。

我对此很新,所以我想知道重写规则中是否有错误,或者我的错误是否在其他地方......

谢谢!

1 个答案:

答案 0 :(得分:0)

您可以在/myapi/public/rest/.htaccess文件中使用此代码:

RewriteEngine On
RewriteBase /myapi/public/rest/

RewriteRule ^home/?$ curso/navigate.php [L,NC]