douren9077 2016-02-10 22:29
浏览 53
已采纳

重定向错误(.htaccess)

I am trying to use .htaccess file for my REST service but I found that the url are not actually redirected. The web server show

Error Message

I wanted to use url such as

/api/v1/test

instead of

/api/v1/rest.php?request=test

I have already check mod_rewrite is acutally working.

My .htaccess file is as below

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule api/v1/(.*)$ api/v1/rest.php?request=$1 [QSA,NC,L]

I have already look at PHP redirecting problem and Sitemap redirecting

  • 写回答

2条回答 默认 最新

  • download1002 2016-02-10 22:34
    关注

    you can try this rule instead because it works with me :

    RewriteRule    api/v1/([A-Za-z0-9-]+)/?$    api/v1/rest.php?request=$1
    

    try putting .htaccess file in htdocs directory and if the directory api location is

    C:\xampp\htdcos\xampp\www\api
    

    then put the full path in the rule

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

报告相同问题?

悬赏问题

  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信