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

何が起こっているのでしょうか?

トラブルシューティングを行うにはどうすればよいですか?

リンクのある Web ページに座って、.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 に答える