【问题标题】:hiding query string with .htaccess inside a folder在文件夹中隐藏带有 .htaccess 的查询字符串
【发布时间】:2012-11-24 10:13:40
【问题描述】:

我想转这个网址:

http://mysite.com/images/?url=20121206/test.jpg&zoom=120&f=g

进入这个:

http://mysite.com/images/20121206/test.jpg?zoom=120&f=g

/images/ 文件夹内的 .htaccess 文件

我在谷歌上搜索了许多正则表达式,但没有工作..请帮忙!

或者可以在图像文件夹之外执行此操作?

【问题讨论】:

    标签: php regex .htaccess url


    【解决方案1】:

    这行得通吗?

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule images/(.*) images/index.php?url=$1 [QSA,L]
    

    【讨论】:

    • 图像仍然没有改变
    【解决方案2】:

    这应该可以完成我认为的工作。

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{QUERY_STRING} url=(.*)
    RewriteRule /images/ /images/%1 [QSA, R]
    

    【讨论】:

    • 已编辑。刚刚意识到您没有在 URL 中指定 index.php 文件。
    • 在浏览器中试用新版本,告诉我它将 URL 重写为什么。
    猜你喜欢
    • 2016-04-16
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-26
    • 1970-01-01
    • 2012-01-23
    相关资源
    最近更新 更多