【问题标题】:How can I remove slash from a url on php? [duplicate]如何从 php 的 url 中删除斜杠? [复制]
【发布时间】:2019-03-01 04:15:45
【问题描述】:

你好其实我有这种类型的网址

https://example.com/cart/index.php
https://example.com/cart/details.php

我想展示这个

https://example.com/cart
https://example.com/cart/details

我如何使用.htaccess 来做到这一点?

我真的尝试在谷歌上查找,但没有任何帮助。

【问题讨论】:

    标签: .htaccess url mod-rewrite


    【解决方案1】:

    这将删除 .index.php 和 .php

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php -f
    RewriteRule ^(.*)$ $1.php [NC,L]
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多