【问题标题】:Getting value with symbol from htaccess从 htaccess 中获取符号的价值
【发布时间】:2015-03-15 08:13:48
【问题描述】:

这个网址

example.com/ad/load.php?id=pay.jpg

会变成

example.com/ad/pay.jpg

我试图这样做.. 但它不起作用。 这是我的 htaccess(进入ad 文件夹)

Options +FollowSymLinks
RewriteEngine On
RewriteBase /ad/

RewriteRule ^(\w+) ./load.php?id=$1

编辑

在这个根 example.com/ad/ 我想显示 index.php 但它没有显示。如何解决它

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    你的正则表达式也应该允许点。在/ad/.htaccess 试试这个:

    DirectoryIndex index.php
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /ad/
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([\w.-]+)/?$ load.php?id=$1 [L,QSA]
    

    【讨论】:

    • . 现在匹配,load.php 将递归。只需排除它,一切都很好。
    • 非常感谢@RaviThapliyal,我最初忽略了它,现在修复了。
    猜你喜欢
    • 1970-01-01
    • 2019-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-11
    • 2020-11-07
    • 2018-09-14
    相关资源
    最近更新 更多