【问题标题】:Apache serves cached content when using mod_rewriteApache 在使用 mod_rewrite 时提供缓存内容
【发布时间】:2020-11-23 20:45:46
【问题描述】:

附加信息:网络服务器在免费共享主机上运行,​​它也使用 cloudflare。

我想这样使用查询字符串:

https://websitename/share/result/参数

而不是这个:

https://websitename/share.php?result=parameter

其中参数是查询字符串值。

我设法通过修改如下所示的 .htaccess 文件来做到这一点:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC]
    RewriteRule ^([^/]+)/([^/]+)$ share.php?result=$1
</IfModule>

当我更新 share.php 文件的内容时,如果我通过导航到以下位置访问它,它会提供新内容:

https://网站名称/分享

但是当我尝试通过以下方式访问它时:

https://websitename/share/ 或通过 https://websitename/share/parameter

它只是提供 share.php 文件的缓存版本。这个问题我该怎么办?

到目前为止我尝试过的事情:

  • 已清除 cloudflare 上的缓存
  • 将缓存级别设置为:无查询字符串
  • 已删除浏览器缓存
  • 试图在其他浏览器中打开网站

【问题讨论】:

  • 您确定服务器可以提供服务吗?您是否尝试清除浏览器缓存?用 wget 额外测试。

标签: php apache .htaccess caching mod-rewrite


【解决方案1】:

我设法解决了这个问题。

解决方案是从此更改 htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC]
    RewriteRule ^([^/]+)/([^/]+)$ share.php?result=$1
</IfModule>

到这里:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^\.]+)$ $1.php [NC]
    RewriteRule ^share/([^/]*)/([^/]*)$ /share?result=$1 [L]
</IfModule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-01
    • 2016-03-25
    • 2010-11-13
    • 1970-01-01
    • 2011-01-31
    • 2014-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多