htaccess删除.php并保留查询字符串问题

时间:2018-10-19 14:34:49

标签: php .htaccess

我在这里有一个端点:

Traceback (most recent call last):
  File "C:\Users\ORJ1GA\.p2\pool\plugins\org.python.pydev.core_6.5.0.201809011628\pysrc\pydevd.py", line 19, in <module>
    from _pydev_bundle import pydev_imports, pydev_log
  File "C:\Users\ORJ1GA\.p2\pool\plugins\org.python.pydev.core_6.5.0.201809011628\pysrc\_pydev_bundle\pydev_imports.py", line 59, in <module>
    from urllib.parse import quote, quote_plus, unquote_plus #@UnresolvedImport
  File "C:\Python27\lib\urllib\parse.py", line 246, in <module>
    """
AttributeError: attribute '__doc__' of 'type' objects is not writable

这是我的htaccess文件:

https://example.com/api/apitest/api-getinfo.php

我不太了解重写,但这就是我想要的:

RewriteEngine On

RewriteRule ^api/apitest/getinfo/(.*)$ /api/apitest/api-getinfo.php?name=$1&%{QUERY_STRING}


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
ErrorDocument 404 /not-found.php

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

<filesMatch "\.( jpg|jpeg|gif|png|ico|js)$">
Header set Cache-Control "max-age=2419200, public, must-revalidate"
</filesMatch>

它可以正常工作,但是URL重写最终看起来像这样:

https://example.com/api/apitest/getinfo/John

我有一种感觉,我在这里想念什么,但我很沮丧!

0 个答案:

没有答案