【问题标题】:Add slash end of the URL after remove .php from file using .htaccess使用 .htaccess 从文件中删除 .php 后添加 URL 的斜线结尾
【发布时间】:2017-05-02 17:18:16
【问题描述】:

我想在从文件中删除 .php 后添加 url 的斜线结尾。 例如。 www.xyz.com/abc/

下面我用过.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php**strong text**

【问题讨论】:

标签: php .htaccess


【解决方案1】:

你可能想要这个

RewriteEngine On
# where the .htaccess file is located (public path from document_root)
RewriteBase /subdir/path/based/on/document_root


# does not apply to existing directories
RewriteCond %{REQUEST_FILENAME} !-d
# rewrite dir-like urls to php script and  END rewriting to avoid infinite loop
RewriteRule (.*)/ $1.php [END]

# apply to existing files only
RewriteCond %{REQUEST_FILENAME} -f
# browser redirect to canonical URL
RewriteRule (.*)\.php$ $1/ [L,R=301]

【讨论】:

    猜你喜欢
    • 2021-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    • 2015-05-09
    相关资源
    最近更新 更多