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条)

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题