location of .htaccess file

ⅰ亾dé卋堺 提交于 2019-12-06 08:02:57

问题


/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--

<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!


回答1:


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.

nano .htaccess (linux users)
edit .htaccess (windows users)




回答2:


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).



来源:https://stackoverflow.com/questions/26756768/location-of-htaccess-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!