【问题标题】:htaccess remove parameter and index filehtaccess 删除参数和索引文件
【发布时间】:2017-01-30 11:10:59
【问题描述】:

我正在尝试删除 proxy.php 文件和传递给它的参数。这是目前的样子。

http://localhost/stuff/proxy.php?parameter=folder01/some.file

这是我想要的样子。

http://localhost/stuff/folder01/some.file

对于我的 htaccess 文件,我尝试了以下方法,但它们不起作用。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /proxy.php?parameter=$1 [L]

还有这个

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+?)/?$ /proxy.php?parameter=$1 [L,QSA]

有什么想法吗?

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    在根目录中尝试或将其放入 stuff 目录并删除 RewriteBase 行。

    RewriteEngine on
    
    RewriteBase /stuff/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteRule ^(.*)$ proxy.php?parameter=$1 [L]
    

    【讨论】:

    • 这对我不起作用。我在根目录和东西目录中尝试过。当我访问 url 时没有任何变化。
    • 您在 stuff 目录中尝试过吗,在 stuff 目录中使用它并删除 RewriteBase /stuff/
    • 我将 htaccess 移到了 stuff 目录并删除了 RewriteBase。什么都没有发生,这很奇怪。而且我确实启用了 mod_rewrite
    • 是否启用了重写 mod_rewrite 请检查stackoverflow.com/questions/3131236/…除此之外还有其他规则工作吗?
    • 我已经在我的 wamp 服务器和生产服务器上尝试过,并且两者都启用了 mod_rewrite,但是您发布的 htaccess 在其中任何一个上都不起作用
    猜你喜欢
    • 1970-01-01
    • 2023-04-04
    • 2012-02-10
    • 1970-01-01
    • 2017-12-27
    • 2018-05-12
    • 1970-01-01
    • 1970-01-01
    • 2017-09-02
    相关资源
    最近更新 更多