【问题标题】:mod_rewrite get variable returns Server errors 500mod_rewrite 获取变量返回服务器错误 500
【发布时间】:2016-01-30 00:40:41
【问题描述】:

我想要做的是让链接显示为这样

http://api.example.com/users/useridhere/

每当我尝试进行重写时,都会出现服务器错误。

这是我当前的代码

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ index.php?id=$1 [NC,L] DirectoryIndex index.php?id=Nobody

如果有人能指出我做错了什么或发布修复,我将不胜感激。

【问题讨论】:

    标签: .htaccess apache2 server-error


    【解决方案1】:

    如果我的理解正确,您希望在浏览器中请求并查看:
    http://api.example.com/users/useridhere/

    但是显示的内容是:
    http://api.example.com/index.php?id=useridhere

    如果这是准确的,那么您的 [docroot]/.htaccess 中可能会有这样的内容:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^users/([\w-]+)$ index.php?id=$1 [NC,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-10
      • 2011-07-09
      • 1970-01-01
      • 2016-02-04
      • 1970-01-01
      • 2015-07-16
      相关资源
      最近更新 更多