بلاگ

نمایش مطالب وبلاگ

برنامه نويسي و ترفندهاي htaccess قسمت دوم

(0 راي‌ها)

در اين قسمت ادامه ی بحث پست قبلی می باشد و به امکانات پیشرفته تر این زبان و ترفند میپردازیم . htaccess. یک فایل متنی بدون اسم میباشد که در روت ( Root ) سایت وجود دارد و میتوانید به آن کدهای زیر را اضافه نمایید .

ساخت صفحات اختصاصی برای خطاهای 400 , 401 , 403 , 404 و 500 :

ErrorDocument 400 400.html
ErrorDocument 401 401.html
ErrorDocument 403 403.html
ErrorDocument 404 404.html
ErrorDocument 500 500.html

توجه : باید در روت سایت خود , فایل های با پسوند html و با نام های 400,401,403,404 و 500 بسازید. حذف پسوند php. در آخر آدرس URL به صورت اتوماتیک :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(([A-Za-z0-9\-]+/)*[A-Za-z0-9\-]+)?$ $1.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

حذف پسوند html. در آخر آدرس URL به صورت اتوماتیک :

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule .* $0.html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L]

تغییر صفحه ی ایندکس سایت : توجه : به صورت پیشفرض , صفحه ابتدایی سایت به صورت index.php یا index.html می باشد که با ترفند زیر میتوانید آن را عوض نمایید .

DirectoryIndex joomla-fars.php

به عنوان مثال در بالا , صفحه اصلی فایل joomla-fars.php قرار داده شده است . تغییر یونیکد تمام سایت به utf-8 :

AddDefaultCharset utf-8

تغییر پسوند فایل های php به html :

RewriteEngine on
RewriteRule ^(.*).htm$ $1.php [nc]

مخفی سازی تمامی فایل ها در دایرکتوری مرورگر :

IndexIgnore *

جلوگیری از باز شدن فایل های شل آپلود شده در وب سایت شما توسط هکر ها ( امنیتی ) :

order allow,deny
deny from all

جلوگیری از ورود یک آی پی خاص :

order allow,deny
deny from 31.8.42.133
allow from all

توجه : میتوانید با کپی خط دوم و درج آی پی های دیگر , از ورود آنها هم جلوگیری نمایید . جلوگیری از ورود تمامی آی پی ها بجر یک آی پی خاص :

order allow,deny
allow from 31.8.42.133
deny from all

توجه : میتوانید با کپی خط دوم و درج آی پی های دیگر , ورود آنها رو هم آزاد نمایید . جلوگیری از ورود تمامی آی پی های خارجی و فقط ورود آی پی های ایران به سایت :

order allow,deny
deny from 2.144.0.0/14
deny from 2.176.0.0/12
deny from 31.7.64.0/18
deny from 31.7.128.0/20
deny from 31.24.200.0/21
deny from 31.24.232.0/21
deny from 31.25.88.0/21
deny from 31.25.104.0/21
deny from 31.25.128.0/21
deny from 31.25.232.0/21
deny from 31.29.32.0/19
deny from 31.40.0.0/21
deny from 31.47.32.0/19
deny from 31.56.0.0/14
deny from 31.130.176.0/20
deny from 31.170.48.0/20
deny from 31.171.216.0/21
deny from 31.184.128.0/18
deny from 31.193.112.0/21
deny from 31.193.144.0/20
deny from 31.217.208.0/21
deny from 37.9.248.0/21
deny from 37.19.80.0/20
deny from 37.32.0.0/19
deny from 37.32.32.0/21
deny from 37.32.40.0/21
deny from 37.32.112.0/20
deny from 37.44.56.0/21
deny from 37.49.144.0/21
deny from 37.63.128.0/17
deny from 37.75.240.0/21
deny from 37.98.0.0/17
deny from 37.98.200.0/21
deny from 37.114.192.0/18
deny from 37.123.192.0/21
deny from 37.128.240.0/20
deny from 37.130.200.0/21
deny from 37.137.0.0/16
deny from 37.143.144.0/21
deny from 37.152.160.0/19
deny from 37.191.64.0/19
deny from 37.221.0.0/18
deny from 46.18.248.0/21
deny from 46.21.80.0/20
deny from 46.28.72.0/21
deny from 46.32.0.0/19
deny from 46.34.96.0/19
deny from 46.34.160.0/19
deny from 46.36.96.0/19
deny from 46.38.128.0/19
deny from 46.100.0.0/16
deny from 46.143.0.0/16
deny from 46.148.32.0/20
deny from 46.164.64.0/18
deny from 46.183.184.0/21
deny from 46.209.0.0/16
deny from 46.224.0.0/16
deny from 46.225.0.0/16
deny from 46.245.0.0/17
deny from 46.248.32.0/19
deny from 46.249.96.0/19
deny from 46.251.160.0/19
deny from 46.255.216.0/21
deny from 62.60.128.0/17
deny from 62.102.128.0/20
deny from 62.193.0.0/19
deny from 62.220.96.0/19
deny from 77.36.128.0/17
deny from 77.77.64.0/18
deny from 77.104.64.0/18
deny from 77.237.64.0/19
deny from 77.237.160.0/19
deny from 77.245.224.0/20
deny from 78.38.0.0/16
deny from 78.39.0.0/16
deny from 78.109.192.0/20
deny from 78.110.112.0/20
deny from 78.111.0.0/20
deny from 78.154.32.0/19
deny from 78.157.32.0/19
deny from 78.158.160.0/19
deny from 79.127.0.0/17
deny from 79.132.192.0/19
deny from 79.170.144.0/21
deny from 79.175.128.0/18
deny from 80.66.176.0/20
deny from 80.69.240.0/20
deny from 80.71.112.0/20
deny from 80.75.0.0/20
deny from 80.191.0.0/16
deny from 80.242.0.0/20
deny from 80.253.128.0/20
deny from 80.253.144.0/20
deny from 81.12.0.0/17
deny from 81.28.32.0/20
deny from 81.28.48.0/20
deny from 81.29.240.0/20
deny from 81.31.160.0/20
deny from 81.31.176.0/20
deny from 81.31.224.0/19
deny from 81.90.144.0/20
deny from 81.91.128.0/20
deny from 81.91.144.0/20
deny from 81.163.0.0/21
deny from 82.99.192.0/18
deny from 82.115.0.0/19
deny from 83.147.192.0/18
deny from 84.47.192.0/18
deny from 84.241.0.0/18
deny from 85.9.64.0/18
deny from 85.15.0.0/18
deny from 85.133.128.0/17
deny from 85.185.0.0/16
deny from 85.198.0.0/18
deny from 86.57.0.0/17
deny from 86.109.32.0/19
deny from 87.107.0.0/16
deny from 87.236.208.0/21
deny from 87.247.160.0/19
deny from 87.248.128.0/19
deny from 88.135.32.0/20
deny from 89.144.128.0/18
deny from 89.165.0.0/17
deny from 89.184.192.0/19
deny from 89.221.80.0/20
deny from 89.235.64.0/18
deny from 91.98.0.0/16
deny from 91.99.0.0/16
deny from 91.184.64.0/19
deny from 91.186.192.0/19
deny from 91.206.122.0/23
deny from 91.207.138.0/23
deny from 91.208.165.0/24
deny from 91.209.242.0/24
deny from 91.212.16.0/24
deny from 91.212.19.0/24
deny from 91.212.252.0/24
deny from 91.216.4.0/24
deny from 91.217.64.0/23
deny from 91.220.79.0/24
deny from 91.222.196.0/22
deny from 91.224.110.0/23
deny from 91.224.176.0/23
deny from 91.225.52.0/22
deny from 91.226.224.0/23
deny from 91.228.189.0/24
deny from 91.229.214.0/23
deny from 91.230.32.0/24
deny from 91.232.64.0/22
deny from 91.232.68.0/23
deny from 91.232.72.0/22
deny from 91.233.56.0/22
deny from 91.236.168.0/23
deny from 91.237.254.0/24
deny from 91.237.255.0/24
deny from 91.238.0.0/24
deny from 92.42.48.0/21
deny from 92.50.0.0/18
deny from 92.61.176.0/20
deny from 92.62.176.0/20
deny from 92.242.192.0/19
deny from 93.110.0.0/16
deny from 93.126.0.0/18
deny from 93.190.24.0/21
deny from 94.74.128.0/18
deny from 94.101.128.0/20
deny from 94.101.176.0/20
deny from 94.101.240.0/20
deny from 94.139.160.0/19
deny from 94.182.0.0/16
deny from 94.183.0.0/16
deny from 94.184.0.0/17
deny from 94.184.128.0/17
deny from 94.232.168.0/21
deny from 94.241.128.0/18
deny from 95.38.0.0/16
deny from 95.80.128.0/18
deny from 95.81.64.0/18
deny from 95.82.0.0/18
deny from 95.82.64.0/18
deny from 95.130.56.0/21
deny from 95.130.240.0/21
deny from 95.142.224.0/20
deny from 109.72.192.0/20
deny from 109.74.224.0/20
deny from 109.95.56.0/21
deny from 109.95.64.0/21
deny from 109.109.32.0/19
deny from 109.110.160.0/19
deny from 109.111.32.0/19
deny from 109.122.192.0/18
deny from 109.125.128.0/18
deny from 109.162.128.0/17
deny from 109.201.0.0/19
deny from 109.203.160.0/19
deny from 109.225.128.0/18
deny from 109.230.64.0/18
deny from 109.238.176.0/20
deny from 109.239.0.0/20
deny from 128.65.160.0/19
deny from 128.140.0.0/17
deny from 130.185.72.0/21
deny from 130.255.192.0/18
deny from 146.66.128.0/21
deny from 146.247.40.0/21
deny from 158.58.184.0/21
deny from 159.20.96.0/20
deny from 159.255.32.0/21
deny from 164.138.16.0/21
deny from 164.138.96.0/21
deny from 164.215.40.0/21
deny from 164.215.56.0/21
deny from 164.215.128.0/17
deny from 176.12.64.0/20
deny from 176.46.128.0/19
deny from 176.56.144.0/20
deny from 176.62.144.0/21
deny from 176.67.64.0/20
deny from 176.101.32.0/20
deny from 176.101.48.0/21
deny from 176.102.224.0/19
deny from 176.221.16.0/20
deny from 176.221.64.0/21
deny from 178.21.40.0/21
deny from 178.21.160.0/21
deny from 178.22.72.0/21
deny from 178.131.0.0/16
deny from 178.157.0.0/18
deny from 178.173.128.0/17
deny from 178.215.0.0/18
deny from 178.219.224.0/20
deny from 178.236.32.0/20
deny from 178.238.192.0/20
deny from 178.239.144.0/20
deny from 178.248.40.0/21
deny from 178.251.208.0/21
deny from 178.252.128.0/18
deny from 178.253.0.0/18
deny from 188.34.0.0/16
deny from 188.75.64.0/18
deny from 188.93.64.0/21
deny from 188.118.64.0/18
deny from 188.121.96.0/19
deny from 188.121.128.0/19
deny from 188.126.128.0/19
deny from 188.136.128.0/17
deny from 188.158.0.0/16
deny from 188.159.0.0/16
deny from 188.191.176.0/21
deny from 188.245.0.0/16
deny from 188.253.0.0/17
deny from 192.188.127.0/24
deny from 193.8.139.0/24
deny from 193.28.181.0/24
deny from 193.104.22.0/24
deny from 193.104.212.0/24
deny from 193.105.2.0/24
deny from 193.105.6.0/24
deny from 193.106.196.0/22
deny from 193.189.122.0/23
deny from 194.60.228.0/22
deny from 194.106.198.0/24
deny from 194.143.140.0/23
deny from 194.146.148.0/22
deny from 194.225.0.0/16
deny from 195.20.136.0/24
deny from 195.88.188.0/23
deny from 195.110.38.0/23
deny from 195.146.32.0/19
deny from 195.170.163.0/24
deny from 195.191.74.0/23
deny from 195.211.44.0/22
deny from 195.245.70.0/23
deny from 196.3.91.0/24
deny from 212.1.192.0/21
deny from 212.16.64.0/19
deny from 212.33.192.0/19
deny from 212.50.224.0/19
deny from 188.136.128.0/17
deny from 188.158.0.0/16
deny from 188.159.0.0/16
deny from 188.191.176.0/21
deny from 188.245.0.0/16
deny from 188.253.0.0/17
deny from 192.188.127.0/24
deny from 193.8.139.0/24
deny from 193.28.181.0/24
deny from 193.104.22.0/24
deny from 193.104.212.0/24
deny from 193.105.2.0/24
deny from 193.105.6.0/24
deny from 193.106.196.0/22
deny from 193.189.122.0/23
deny from 194.60.228.0/22
deny from 194.106.198.0/24
deny from 194.143.140.0/23
deny from 194.146.148.0/22
deny from 194.225.0.0/16
deny from 195.20.136.0/24
deny from 195.88.188.0/23
deny from 195.110.38.0/23
deny from 195.146.32.0/19
deny from 195.170.163.0/24
deny from 195.191.74.0/23
deny from 195.211.44.0/22
deny from 195.245.70.0/23
deny from 196.3.91.0/24
deny from 212.1.192.0/21
deny from 212.16.64.0/19
deny from 212.33.192.0/19
deny from 212.50.224.0/19
deny from 212.80.0.0/19
deny from 212.86.64.0/19
deny from 212.95.128.0/19
deny from 212.120.192.0/19
deny from 213.147.128.0/19
deny from 213.176.0.0/19
deny from 213.176.32.0/19
deny from 213.176.64.0/18
deny from 213.195.0.0/18
deny from 213.207.192.0/18
deny from 213.217.32.0/19
deny from 213.233.160.0/19
deny from 217.11.16.0/20
deny from 217.24.144.0/20
deny from 217.25.48.0/20
deny from 217.64.144.0/20
deny from 217.66.192.0/20
deny from 217.66.208.0/20
deny from 217.146.208.0/20
deny from 217.170.240.0/20
deny from 217.172.96.0/19
deny from 217.174.16.0/20
deny from 217.218.0.0/16
deny from 217.219.0.0/16
allow from all

نمايش بخش اول آموزش

نمايش آموزش در انجمن طراحان قالب

بازديد 878 بار

تماس با ما

  • کرج خ بهشت  خیابان اول کوچه سوم پلاک4
  • تلفن: 33935083 - 09301514009
    تماس از ساعت 14 الی22

درباره ما   -   قوانین و مقررات