dongpu6141 2014-05-25 17:18
浏览 35
已采纳

我的.htaccess无法正常工作[关闭]

I have this .htaccess below, with my rule, my index.php is my default, is where I acess all, where I want to do my navigation, this index also recover variable url:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1

Then I have my function getHome() to handle url, for now Im just echo my $url, that was supposed to get the value passed by url:

function getHome(){
    $url = $_GET['url'];
    echo $url;
}

Than I have my index.php where Im calling my getHome(), and for now Im testing, passing some values on my url.

But when I pass some random values into my url, I'm getting always "Object not found!....Error 404"

But I wanted to echo my values that I passed in the URL.

Do you see what am I doing wrong?

Update:

Im had a <? instread of <?php in my code, and now Im having an error:

Notice: Undefined index: url in $url = $_GET['url'];

I update my function to:

$url = isset($_GET['url']);

And now I dont have undefined index error, but I have the same error before, when I pass some random values to my URL, I always get my "Object not found...Error 404".

  • 写回答

2条回答 默认 最新

  • dqbh8054 2014-05-25 17:41
    关注

    This should be working, but as an alternative you could also use:

    $url = $_SERVER['REQUEST_URI'];
    

    Then you would not have to check if anything is set or pass a query variable in your rewrite rule.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 hexo+github部署博客
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?