【问题标题】:Friendly URL's returns 404友好 URL 返回 404
【发布时间】:2019-12-03 18:14:37
【问题描述】:


大家好。

我的 htaccess 文件有问题。我创建了友好的 url,但服务器返回 404 错误,我找不到我在代码中出错的地方。我花了3个小时在上面,仍然没有。求各位大神帮忙:D

这是我的代码:

选项 - 索引 DirectoryIndex index.php 重写引擎开启 RewriteBase / 重写规则 ^([a-zA-Z0-9-_/]+)$ /$1.php [L,NC,QSA] 重写规则 ^([a-zA-Z0-9-_/]+).(php|html|htm)$ /$1 [NC,R=301,L] 重写规则 ^index.(php|html|htm)$ / [R=301,L]

重定向正常,但服务器返回 404 错误而不是显示网站。

我想制作如下示例的网址:

发件人:
www.domain.com/customers.php
www.domain.com/products/number1.php

收件人:
www.domain.com/customers
www.domain.com/products/number1

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    好的,我解决了这个问题,但现在我有一个重定向循环:(

    新代码:

    选项 - 索引 DirectoryIndex index.php 重写引擎开启 RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f 重写规则 ^([^.]+)$ $1.php [NC,L] 重写规则 ^([a-zA-Z0-9-_/]+).(php|html|htm)$ /$1 [NC,R=301,L] 重写规则 ^index.(php|html|htm)$ / [R=301,L]

    【讨论】:

      【解决方案2】:

      试试这个

       RewriteOptions inherit
      <IfModule mod_rewrite.c>
       RewriteEngine on 
       RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-f 
       RewriteCond %{REQUEST_FILENAME} !-d 
       RewriteRule ^(.*)$ index.php?/$1 [L]
      </IfModule>
      

      【讨论】:

        猜你喜欢
        • 2013-03-02
        • 2014-08-29
        • 1970-01-01
        • 2017-06-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-24
        • 1970-01-01
        相关资源
        最近更新 更多