[英]Remove trailing /index.php from url using .htaccess
我正在使用PHP作為API服務器來構建一個角度應用程序。 我想清除角度post
方法中的尾隨/index.php
。 我嘗試使用如下的.htaccess
文件
######### Begin - RewriteEngine enabled
RewriteEngine On
########## End - RewriteEngine enabled
########## remove index.php from the end of URI
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]
##########
我的網址結構如下
http://localhost/api/auth/index.php
我http://localhost/api/auth
一樣訪問它
現在我可以通過使用獲取帖子數據
this.http.post('/api/auth/', parameters, request.options)
但我不希望/
在URL的結尾。 如何在.htaccess
文件中添加此條件? 任何幫助,將不勝感激。
添加RewriteRule
追加斜杠。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ /$1/ [L,R=301]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.