هاست لینوکس

آخرین بسته‌ی MyBB: نسخه‌ی 1.8.27 MyBB منتشر شد


امتیاز موضوع:
  • 0 رأی - میانگین امتیازات: 0
  • 1
  • 2
  • 3
  • 4
  • 5
بهترین کد برای .htaccess چیه
#1
بهترین کد برای .htaccess چیه؟ من خودم از این کد ها استفاده میکنم ولی تاثیر زیادی نداره:

کد:
کد بالا اومدن انجمن مثل جت

# BEGIN Browser Caching/Headers
<IfModule mod_mime.c>
AddType text/css .css
AddType application/x-javascript .js
AddType image/svg+xml .svg .svgz
AddType text/plain .txt
AddType text/xsd .xsd
AddType text/xsl .xsl
AddType text/xml .xml
AddType video/asf .asf .asx .wax .wmv .wmx
AddType video/avi .avi
AddType image/bmp .bmp
AddType application/java .class
AddType video/divx .divx
AddType application/msword .doc .docx
AddType application/x-msdownload .exe
AddType image/gif .gif
AddType application/x-gzip .gz .gzip
AddType image/x-icon .ico
AddType image/jpeg .jpg .jpeg .jpe
AddType application/vnd.ms-access .mdb
AddType audio/midi .mid .midi
AddType video/quicktime .mov .qt
AddType audio/mpeg .mp3 .m4a
AddType video/mp4 .mp4 .m4v
AddType video/mpeg .mpeg .mpg .mpe
AddType application/vnd.ms-project .mpp
AddType application/vnd.oasis.opendocument.database .odb
AddType application/vnd.oasis.opendocument.chart .odc
AddType application/vnd.oasis.opendocument.formula .odf
AddType application/vnd.oasis.opendocument.graphics .odg
AddType application/vnd.oasis.opendocument.presentation .odp
AddType application/vnd.oasis.opendocument.spreadsheet .ods
AddType application/vnd.oasis.opendocument.text .odt
AddType audio/ogg .ogg
AddType application/pdf .pdf
AddType image/png .png
AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
AddType audio/x-realaudio .ra .ram
AddType application/x-shockwave-flash .swf
AddType application/x-tar .tar
AddType image/tiff .tif .tiff
AddType audio/wav .wav
AddType audio/wma .wma
AddType application/vnd.ms-write .wri
AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
AddType application/zip .zip
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css A31536000
ExpiresByType application/x-javascript A31536000
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
ExpiresByType text/xsd A3600
ExpiresByType text/xsl A3600
ExpiresByType text/xml A3600
ExpiresByType video/asf A31536000
ExpiresByType video/avi A31536000
ExpiresByType image/bmp A31536000
ExpiresByType application/java A31536000
ExpiresByType video/divx A31536000
ExpiresByType application/msword A31536000
ExpiresByType application/x-msdownload A31536000
ExpiresByType image/gif A31536000
ExpiresByType application/x-gzip A31536000
ExpiresByType image/x-icon A31536000
ExpiresByType image/jpeg A31536000
ExpiresByType application/vnd.ms-access A31536000
ExpiresByType audio/midi A31536000
ExpiresByType video/quicktime A31536000
ExpiresByType audio/mpeg A31536000
ExpiresByType video/mp4 A31536000
ExpiresByType video/mpeg A31536000
ExpiresByType application/vnd.ms-project A31536000
ExpiresByType application/vnd.oasis.opendocument.database A31536000
ExpiresByType application/vnd.oasis.opendocument.chart A31536000
ExpiresByType application/vnd.oasis.opendocument.formula A31536000
ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
ExpiresByType application/vnd.oasis.opendocument.text A31536000
ExpiresByType audio/ogg A31536000
ExpiresByType application/pdf A31536000
ExpiresByType image/png A31536000
ExpiresByType application/vnd.ms-powerpoint A31536000
ExpiresByType audio/x-realaudio A31536000
ExpiresByType application/x-shockwave-flash A31536000
ExpiresByType application/x-tar A31536000
ExpiresByType image/tiff A31536000
ExpiresByType audio/wav A31536000
ExpiresByType audio/wma A31536000
ExpiresByType application/vnd.ms-write A31536000
ExpiresByType application/vnd.ms-excel A31536000
ExpiresByType application/zip A31536000
</IfModule>
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
BrowserMatch bMSI[E] !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</IfModule>
</IfModule>
<FilesMatch "\.(css|js|CSS|JS)$">
<IfModule mod_headers.c>
Header set Pragma "public"
Header append Cache-Control "public, must-revalidate, proxy-revalidate"
</IfModule>
FileETag MTime Size
</FilesMatch>
<FilesMatch "\.(rtf|rtx|svg|svgz|xsd|xsl|xml|RTF|RTX|SVG|SVGZ|XSD|XSL|XML)$">
<IfModule mod_headers.c>
Header set Pragma "public"
Header append Cache-Control "public, must-revalidate, proxy-revalidate"
</IfModule>
FileETag MTime Size
</FilesMatch>
<FilesMatch "\.(asf|asx|wax|wmv|wmx|avi|bmp|divx|doc|doc x|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mo v|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf| odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ra m|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xl w|zip|ASF|ASX|WAX|WMV|WMX|AVI|BMP|DIVX|DOC|D OCX|EXE|GIF|GZ|GZIP|ICO|JPG|JPEG|JPE|MDB|MID|MIDI| MOV|QT|MP3|M4A|MP4|M4V|MPEG|MPG|MPE|MPP|ODB|ODC|OD F|ODG|ODP|ODS|ODT|OGG|PDF|PNG|POT|PPS|PPT|PPTX|RA| RAM|SWF|TAR|TIF|TIFF|WAV|WMA|WRI|XLA|XLS|XLSX|XLT| XLW|ZIP)$">
<IfModule mod_headers.c>
Header set Pragma "public"
Header append Cache-Control "public, must-revalidate, proxy-revalidate"
</IfModule>
FileETag MTime Size
</FilesMatch>
# End Browser Caching/Headers


کد زبان پیش فرض

# pass the default character set
AddDefaultCharset utf-8


کد محافظت از .htaccess

<files ".htaccess">
order allow,deny
deny from all
</files>

کد جلوگیری از سرقت فایلهای و فولدرهای درون هاست

Options All -Indexes



کد محافظت ازconfig.php

<files config.php>
order allow,deny
deny from all
</files>


کد زیپ کردن

<IfModule mod_deflate.c>
   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css  application/x-javascript
   BrowserMatch ^Mozilla/4 gzip-only-text/html
   BrowserMatch ^Mozilla/4\.0[678] no-gzip
   BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>


کد جلوگیری از سرقت عکس ها

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?klhsr.ir/.*$ [NC]
RewriteRule \.(gif|jpg|css)$ - [F]
پاسخ
 سپاس شده توسطمحمد محمدی (۱۳۹۳/۱۱/۲۵، ۱۵:۵۰:۰۸ عصر)
#2
یعنی چی بهترین کد؟
این فایل پیکربندی برای سرور آپاچی هست
بستگی به چیزی که میخواید بدست بیارید باید تنظیم بشه

تنظیماتی مثل ریدایرکت کردن، تغییر نام یا فرمت فایل یا فولدر ها، محدودیت دسترسی به فولدر ها و ... رو میشه انجام داد
پاسخ
#3
یعنی بهترین کدایی که برای امنیت و سرعت لود شدن سایت باشه چیه.به جز اون تنظیمات شخصی.
پاسخ
#4
آدرس‌ها رو درست معرفی کنید مطمئناً جواب خواهید گرفت

کد:
# BEGIN .htaccess Security
<files ".htaccess">
order allow,deny
deny from all
</files>
# END .htaccess Security

# BEGIN Indexs Security
Options All -Indexes
# END Indexs Security

# BEGIN Pass The Default Character Set
AddDefaultCharset utf-8
# END Pass The Default Character Set

# BEGIN Error Files
ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php
# END Error Files

# BEGIN Limit GET POST
<Limit GET POST>
order allow,deny
deny from 200.49.176.139
allow from all
</Limit>
# END Limit GET POST

# BEGIN Limit Spam
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*weho.ir* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
# END Limit Spam

# BEGIN Remove Category
RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]
# END Remove Category

# BEGIN Change .php to .html
DirectoryIndex file.php file.html
# END Change .php to .html

# BEGIN Disable WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} !^yoursite\.com$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
# END Disable WWW

# BEGIN Enable WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# END Enable WWW

# BEGIN Config Security
<files inc/config.php>
order allow,deny
deny from all
</files>
# END Config Security

# BEGIN New Formats
AddType application/x-httpd-php .asp .jsp
AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
# END New Formats

# BEGIN Redirect
Redirect /Dirold/old.html http://site.com/DirNew/new.html
# END Redirect

# BEGIN Limit FollowSymlinks
Options +FollowSymlinks
RewriteEngine On
Rewritecond %{REQUEST_FILENAME} !^(.+).css$
Rewritecond %{REQUEST_FILENAME} !^(.+).js$
Rewritecond %{REQUEST_FILENAME} !file.php$
RewriteRule ^(.+)$ /deny/ [nc]
# END Limit FollowSymlinks

# BEGIN Limit Upload Max
php_value upload_max_filesize 40M
# END Limit Upload Max

# BEGIN Limit Upload Post
php_value post_max_size 4M
# END Limit Upload Post

# BEGIN Limit Request Time
php_value max_execution_time 200
# END Limit Request Time

# BEGIN Limit Get & Post
php_value max_input_time 250
# END Limit Get & Post

# BEGIN Images Security
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?site.com/ .*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
# END Images Security

# BEGIN Plugins Security
RewriteEngine On
RewriteBase /
RewriteRule ^inc/plugins - [F,L]
RewriteRule !^inc/plugins - [S=3]
RewriteRule ^inc/plugins/[^/]+\.php$ - [F,L]
RewriteRule ^inc/plugins/.+\.php - [F,L]
RewriteRule ^inc/plugins/ - [F,L]
# END Plugins Security

# BEGIN Compress Text Files
<ifModule mod_deflate.c>
<filesMatch "\.(css|js|x?html?|php|woff|ttf|png|jpg|gif)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
# END Compress Text Files

# BEGIN Expire Headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
</ifModule>
# END Expire Headers

# BEGIN Cache Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf|woff|ttf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=2592000, private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache Control Headers

# BEGIN Turn ETags Off
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
# END Turn ETags Off

# BEGIN Remove Last Modified Header
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
# END Remove Last Modified Header
پاسخ
#5
(۱۴۰۰/۷/۱۵، ۱۵:۱۴:۴۳ عصر)BamikMarket نوشته است: آدرس‌ها رو درست معرفی کنید مطمئناً جواب خواهید گرفت

کد:
# BEGIN .htaccess Security
<files ".htaccess">
order allow,deny
deny from all
</files>
# END .htaccess Security

# BEGIN Indexs Security
Options All -Indexes
# END Indexs Security

# BEGIN Pass The Default Character Set
AddDefaultCharset utf-8
# END Pass The Default Character Set

# BEGIN Error Files
ErrorDocument 401 /error/401.php
ErrorDocument 403 /error/403.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/500.php
# END Error Files

# BEGIN Limit GET POST
<Limit GET POST>
order allow,deny
deny from 200.49.176.139
allow from all
</Limit>
# END Limit GET POST

# BEGIN Limit Spam
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*weho.ir* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
# END Limit Spam

# BEGIN Remove Category
RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]
# END Remove Category

# BEGIN Change .php to .html
DirectoryIndex file.php file.html
# END Change .php to .html

# BEGIN Disable WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} !^yoursite\.com$ [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
# END Disable WWW

# BEGIN Enable WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# END Enable WWW

# BEGIN Config Security
<files inc/config.php>
order allow,deny
deny from all
</files>
# END Config Security

# BEGIN New Formats
AddType application/x-httpd-php .asp .jsp
AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes
# END New Formats

# BEGIN Redirect
Redirect /Dirold/old.html http://site.com/DirNew/new.html
# END Redirect

# BEGIN Limit FollowSymlinks
Options +FollowSymlinks
RewriteEngine On
Rewritecond %{REQUEST_FILENAME} !^(.+).css$
Rewritecond %{REQUEST_FILENAME} !^(.+).js$
Rewritecond %{REQUEST_FILENAME} !file.php$
RewriteRule ^(.+)$ /deny/ [nc]
# END Limit FollowSymlinks

# BEGIN Limit Upload Max
php_value upload_max_filesize 40M
# END Limit Upload Max

# BEGIN Limit Upload Post
php_value post_max_size 4M
# END Limit Upload Post

# BEGIN Limit Request Time
php_value max_execution_time 200
# END Limit Request Time

# BEGIN Limit Get & Post
php_value max_input_time 250
# END Limit Get & Post

# BEGIN Images Security
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?site.com/ .*$ [NC]
RewriteRule \.(gif|jpg|swf|flv|png)$ /feed/ [R=302,L]
# END Images Security

# BEGIN Plugins Security
RewriteEngine On
RewriteBase /
RewriteRule ^inc/plugins - [F,L]
RewriteRule !^inc/plugins - [S=3]
RewriteRule ^inc/plugins/[^/]+\.php$ - [F,L]
RewriteRule ^inc/plugins/.+\.php - [F,L]
RewriteRule ^inc/plugins/ - [F,L]
# END Plugins Security

# BEGIN Compress Text Files
<ifModule mod_deflate.c>
<filesMatch "\.(css|js|x?html?|php|woff|ttf|png|jpg|gif)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
# END Compress Text Files

# BEGIN Expire Headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
</ifModule>
# END Expire Headers

# BEGIN Cache Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf|woff|ttf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "max-age=2592000, private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache Control Headers

# BEGIN Turn ETags Off
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
# END Turn ETags Off

# BEGIN Remove Last Modified Header
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
# END Remove Last Modified Header
موارد اضافی مثلا برای وردپرس دیده شد یا ریدایرکت از محلی به محل دیگه

بیشتر شبیه برگه تقلبه تا htaccess معتبر.
تو استفاده از این فایل باید خیلی دقت کنید
نصب و آپدیت انجمن مای بی بی | پلاگین و پوسته | تغییرات داخلی انجمن
نصب و بروزرسانی وردپرس طراحی پوسته های وردپرسی سبک با سئوی بالا
شخصی سازی پوسته های مای بی بی و وردپرس
طراحی سیستم مدیریت محتوای اختصاصی و خاص با برترین زبان های برنامه نویسی دنیا
جهت سفارش در تلگرام: firstboy000@
پاسخ


پرش به انجمن:


کاربرانِ درحال بازدید از این موضوع: 1 مهمان