dongzhang0418 2014-08-19 15:47
浏览 66
已采纳

PHP重定向在mod_rewrite(.htaccess)文件后停止工作

My redirect logic has stopped working ever since I've put the following code

Options -Indexes
ErrorDocument 404 /site3/public/admin/filenotfound.php

RewriteEngine On
RewriteBase /site3/public/admin/

RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^ - [L]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)?\&picid=([^&\s]+)\s [NC]
RewriteRule ^ %1/caseid/%2/picid/%3/? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/picid/([^/]+)/?$ $1.php?caseid=$2&picid=$3 [L,NC,QSA]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?caseid=([^&\s]+)\s [NC]
RewriteRule ^ %1/caseid/%2/? [R=302,L,NE]

RewriteCond %{THE_REQUEST} \s([^.]+?)(?:\.php)?\?search=([^&\s]+)\s [NC]
RewriteRule ^ %1/search/%2/? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/caseid/([^/]+)/?$ $1.php?caseid=$2 [L,NC,QSA]

## hide .php extension snippet    
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} \s([^.]+)\.php [NC]
RewriteRule ^ %1/ [R=302,L,NE]

# add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

this is how i'm redirecting my page

function redirectTO($url = null){
    if($url != null){
        header("Location:{$url}");
        exit();
    }
}

redirectTO('page.php');

I'm not a very good of mode rewriting therefore i cannot work out where the issue is please advise me what should, by the way they work fine if remove my .htaccess file doesn't work if put that file back on.

Any Idea?

  • 写回答

2条回答 默认 最新

  • dounaidu0204 2014-08-19 15:52
    关注

    use full path of your of the URL i.e. www.example.com/page.php

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

报告相同问题?

悬赏问题

  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏
  • ¥15 STM32串口接收问题