douchao0358 2015-04-04 08:50
浏览 33

Htaccess Redirect for API

I want to redirect every .htaccess call to a particular file.

I want to redirect all Get/Put/Post/Delete calls to a folder to a specific index.php file.

I have following directory structure:

\var\www\html\app

inside app i have a file index.php

Now i want any calls like

GET http(s)://myWeb.com/app 
POST http(s)://myWeb.com/app 
GET http(s)://myWeb.com/app/helloworld

to redirect to

\var\www\html\app\index.php

Here is my failed attempt:

RewriteEngine On
RewriteBase /app/
RewriteRule ^ app/index.php [QSA,L]
#RewriteRule ^ index.php [QSA,L]   //Tried this one as well

This .htaccess is inside

/var/www/html

I also placed a similar htaccess inside app folder but it doesnt works too.

Should i use 2 htaccess files ? If one what should be the format for it ?

Also, is there a tool to check htaccess regex ? something like www.regexr.com

  • 写回答

1条回答 默认 最新

  • dos49618 2015-05-12 12:48
    关注

    Did you try this?

    RewriteRule . app/index.php [R,L]
    

    I think QSL is needed only if you want to pass the URL queries

    评论

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序