.htaccessファイルについては何も知らないので、皆さんに助けを求めています。私はコードでやろうとしていたことを列挙し、それは動作していません。私の.htaccessファイルには何かがないか間違っていますか?
- 私のURLから.htmlと.phpを削除してください。
- 画像や.js/.cssのようなファイルを圧縮します(Googleスピードテストはこれが起こっていないと言います)。
- ウェブサイトがwwwの有無にかかわらず動作するようにします(標準はwwwなし)。
これはそれです。事前にあなたに助けてくれてありがとう!
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<FilesMatch "(\. (engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)? |xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
Options -Indexes
RewriteEngine on
RewriteRule ^/abc/(.*)$ /new/$1 [R=301,L]
RewriteEngine on
RewriteRule ^/def/(.*)\.html$ /new2/$1.html [R=301,L]
RewriteEngine on
RewriteRule ^/ghi/(.*)\.(html|htm)$ /new3/$1.$2 [R=301,L]
RewriteEngine on
RewriteRule ^/jkl/(.*)$ http://www.mywebsite.com/$1 [R=301,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
「私が起こると予想されていたことは起こっていない」それで正確には何ですか? –
こんにちは@PanamaJack、私は自分のページから拡張子(.html)を削除しようとしていました。私は.htaccessファイルに関するいくつかの情報を収集し、自分自身を書き込もうとしましたが、私のページにはまだ拡張機能があります。また、私はGoogleのスピードをチェックするとき、私のウェブサイトは画像とファイルを圧縮しないと言います。私はまたその.htaccessでそれを作りたかった。 –
あなたのページからエクステンションを削除することによって、あなたが意味することを説明してください。 html拡張機能がコードから削除されることを期待していますか?または、かなりのURLを使用したいですか?あなたはアドレスバーにあなたが見たいと思うものをより良く説明してください。 –