Html .htaccess 文件的位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26756768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
location of .htaccess file
提问by Unique
/var/www/html/My_project_folder is the path to my project. I did not find .htaccess file. I want to paste my edited .htaccess file . but i am not sure in which location i need to put? My htaccess file code is--
/var/www/html/My_project_folder 是我的项目的路径。我没有找到 .htaccess 文件。我想粘贴我编辑过的 .htaccess 文件。但我不确定我需要放在哪个位置?我的 htaccess 文件代码是——
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year”
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month”
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
This code i added in .htaccess file to speed up of my site. Please help me for location of .htaccess file. Thanks in Advance!
我在 .htaccess 文件中添加了这段代码来加速我的网站。请帮我找到 .htaccess 文件的位置。提前致谢!
回答by davide andreazzini
You need to paste the .htaccess file on the root of your project. It's possible that your .htaccess is hidden ... try to look into the folder using the terminal instead of the DM and if it's not there try to create a new file from the terminal using the command.
您需要将 .htaccess 文件粘贴到项目的根目录中。您的 .htaccess 可能被隐藏了......尝试使用终端而不是 DM 查看文件夹,如果它不存在,请尝试使用命令从终端创建一个新文件。
nano .htaccess (linux users)
edit .htaccess (windows users)
nano .htaccess(linux 用户)
编辑 .htaccess(windows 用户)
回答by Kirschi
Usually this file goes to the root of your website (where your index.php
file is). If there is none, you can create a new file. But watch out not to create something like ".htaccess.txt" if you do it with notepad (which usually appends .txt to all files).
通常,此文件会转到您网站的根目录(您的index.php
文件所在的位置)。如果没有,您可以创建一个新文件。但是,如果您使用记事本(通常会将 .txt 附加到所有文件),请注意不要创建类似“.htaccess.txt”的内容。