dongshi9526 2015-04-26 16:42
浏览 299

配置Nginx以隐藏index.php并重定向到

Is possible to do this same code (Apache .htaccess) on Nginx Server?

<IfModule mod_rewrite.c>
    RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

The most important for me in this case, is preservs a $_SERVER['QUERY_STRING'] with all contents after a localhost/root/$query_string

I'm developing a framework PHP using HHVM, the only thing that I want is hide a "index.php" or "index.hh", without redirect to 404 Nginx or load a index.php/index.php inside my nginx's root projects folders

  • 写回答

1条回答 默认 最新

  • doudiandi6967 2015-04-27 04:05
    关注

    Have you tried using try_files?

    location / {
        try_files $uri $uri/ /index.php?$args
    } 
    

    Then, configure your index.php to catch your query string with $_SERVER['QUERY_STRING'] as stated above.

    Check out the WordPress nginx configuration for an example: https://codex.wordpress.org/Nginx

    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程