【发布时间】:2015-07-22 09:29:58
【问题描述】:
我想重写规则以允许这样的路径:
http://example.com/api/somemethod/ api是一个api.php文件,包含api类。
我已经在 .htaccess 中重写了规则,但是如果我尝试在上面链接,我得到一个错误:
Object not found! The requested URL was not found on this server. If
you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
这是我的 .htaccess 文件:
重写引擎开启
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ api.php?x=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ api.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ api.php [QSA,NC,L]
【问题讨论】:
标签: php apache .htaccess mod-rewrite