【问题标题】:.htaccess simple rewrite rule not working in subdirectory.htaccess 简单的重写规则在子目录中不起作用
【发布时间】:2017-06-21 13:50:30
【问题描述】:

我正在处理一个子目录,并且想将丑陋的文件 URL 重写为更漂亮的 URL。

喜欢: domain.com/myfolder/myreport.php --> domain.com/myfolder/MyReport/

这是我所拥有的:

RewriteEngine On  
RewriteRule    ^test/?$    index.php    [NC,L]    

取自here

但是,它不起作用。我已经测试了我能想象到的所有正则表达式组合,但没有任何效果。

还有其他潜在的问题吗?是否有可能所有规则都被根目录中的规则或其他规则忽略/覆盖?

正在使用 .htaccess,如果我添加“测试”,我会收到 500 错误。

【问题讨论】:

    标签: php .htaccess url-rewriting


    【解决方案1】:

    你可以试试下面的,

    RewriteEngine on
    RewriteBase /myfolder/
    RewriteRule ^(.*)$ /myfolder/index.php?/$1 [L]
    

    【讨论】:

    • 天哪,它正在工作 - 谢谢!但是,当我输入“.../test/”时,它被重定向到“.../index.php” - 是否可以在实际显示文件时将 URL 保持在“.../test/”?
    猜你喜欢
    • 1970-01-01
    • 2018-10-16
    • 2017-10-06
    • 2017-01-13
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多