.htaccess 没有删除这个:index.php?
.htaccess not removing this: index.php?
所以,我最近为我的一个网站编写了 PHP API,但我试图让它删除 ?
和index.php
一起,假设我去http://api.url.com/index.php?Method
我实际上可以去 http://api.url.com/Method 并且它的工作方式与它一样。
我试过其他 .htaccess 的 但似乎没有任何效果。
在您的 .htaccess 文件中写入以下代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
所以,我最近为我的一个网站编写了 PHP API,但我试图让它删除 ?
和index.php
一起,假设我去http://api.url.com/index.php?Method
我实际上可以去 http://api.url.com/Method 并且它的工作方式与它一样。
我试过其他 .htaccess 的 但似乎没有任何效果。
在您的 .htaccess 文件中写入以下代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>