1

我正在尝试关注https://github.com/crwilliams/diary-user-interface/wiki/cachebusting

如果我将我的 HTML 代码设置为:

  href="/myDir/myFile.2013103000.html"

并添加到 .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.+)\.(\d+)\.(html)$ $1.$3 [L]
</IfModule>

当浏览器转到以下位置时,我看到“找不到页面”错误:https://www.mycompany.com/myDir/myFile.2013103000.html

知道会发生什么吗?

我能做些什么来排除故障?

坐在带有链接的网页上,如果我将 .htaccess 更改为此:

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule ^(.+) https://www.mycompany.com/myDir/myFile.html [L]  
</IfModule>

然后单击它工作的链接(但显然这只是为了排除故障)。

更新

这是完整的 .htaccess 文件,以防可以将上述内容确定为问题:

# attempt to implement version control with cachebusting
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.(\d+)\.(html)$ $1.$3 [L]
</IfModule>

# Pruning irrelevant parts (Phil)

# force SSL and www
RewriteCond %{HTTP_HOST} ^mycompany\.com$ [OR]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.mycompany.com/$1 [R=301,L]

# Redirect index.html to a specific subfolder;
Redirect permanent /index.html https://www.mycompany.com/home/

# enable pretty url
<IfModule mod_rewrite.c>
    RewriteBase /home/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME}/index.html !-f
    RewriteCond %{REQUEST_FILENAME}/index.php !-f
    RewriteRule . index.php [L]
</IfModule>
4

1 回答 1

1

我会删除最后一个块并将其放在.htaccess您目录中的单独文件中/home,例如

# /home/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    # not sure about the next 3 lines though
    RewriteCond %{REQUEST_FILENAME}/index.html !-f
    RewriteCond %{REQUEST_FILENAME}/index.php !-f
    RewriteRule . index.php [L]
</IfModule>
于 2013-10-31T00:27:54.083 回答