کاربر مهمان، خوش آمديد!  ( ورود - عضويت ) جهت سفارش با شماره 09122335943 و 09365516166 و تماس بگیرید.مدیریت سایت صادقی امروز 29 آبان ماه ، 1387   
 
منو اصلي

لينكهاي سريع
 صفحه اصلي
 نقشه سايت
 طراحي سايت
  ايميل ماركتينگ
  آگهي و تبليغات
 فروشگاه اينترنتي
  انجمن برق و الكترونيك
 پروژه هاي الكترونيكي
 تالار گفتمان
 چت روم
 درباره ما
 تماس با ما

امكانات سايت
 لينك دوستان
 گالري عكس
 كليپ جالب
 تبليغات
 دريافت فايل
 مقالات سايت
 لينكستان
 فال حافظ
 آموزش ها
 سوالات رايج

بخش خبري
 نمايش ساده
 موضوعات اخبار
 آرشيو اخبار
 تيتر سايتهاي خبري
 ارسال خبر
 نظر سنجي

بخش كاربري
 برترين ها
 آمار بازديد
 ليست اعضا
 نوشته هاي روزانه
 جستجو
 معرفي به دوستان
 گروههاي كاربري
 پيغام شخصي
  موقعيت اعضا



پیغام کوتاه

فقط کاربران عضو سايت ميتوانند پيغام کوتاه ارسال نمايند لطفا وارد سيستم شويد يا اينکه عضو شويد.

آخرین ارسالها
کل موضوعات 137
کل ارسال ها 200
کل بازديد ها 19192
کل پاسخ ها 63
کل اعضا 315
آخرين 20 ارسال انجمن

دروبين موبايل خودكار روشن!!!!
ارسال شده توسط pcnewpinky در مورخه : شنبه، 27 مهر ماه ، 1387

دانلود كتابهاي روباتيك
ارسال شده توسط abel916 در مورخه : پنجشنبه، 25 مهر ماه ، 1387

سوالات و مشکلات متداول نیوک
ارسال شده توسط iman4web در مورخه : سه شنبه، 2 مهر ماه ، 1387

استاندارد فایل Robot.txt
ارسال شده توسط iranwebco در مورخه : يكشنبه، 24 شهريور ماه ، 1387

شماری از پرسشهای رايج کاربران گوگل
ارسال شده توسط iranwebco در مورخه : يكشنبه، 24 شهريور ماه ، 1387

همه چيز درباره ی گوگل
ارسال شده توسط iranwebco در مورخه : يكشنبه، 24 شهريور ماه ، 1387

قابليتهاي مخصوص Google
ارسال شده توسط iranwebco در مورخه : يكشنبه، 24 شهريور ماه ، 1387

وردپرس های خود را SEO کنیم
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

۱۰+۱ نکته برای انتخاب یک پوسته ی مناسب وردپرس
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

تگ چه دارد؟ - What's in a Tag
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

سئو (SEO) چیست؟
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

معرفی چند موتور جستجوی معروف
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

موتورهاي جستجو چگونه کار مي کنند؟
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

فرهنگنامه سئو
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

اهمیت سئو (SEO)
ارسال شده توسط iman4web در مورخه : جمعه، 15 شهريور ماه ، 1387

ترفندهای .htaccess
ارسال شده توسط iman4web در مورخه : يكشنبه، 27 مرداد ماه ، 1387

SEO و SEM چیستند؟
ارسال شده توسط iman4web در مورخه : يكشنبه، 27 مرداد ماه ، 1387

CSS چيست؟
ارسال شده توسط iman4web در مورخه : شنبه، 26 مرداد ماه ، 1387

طراحی وب سایت شما با سیستم جوملا
ارسال شده توسط iman4web در مورخه : شنبه، 26 مرداد ماه ، 1387

آموزشphp مبتدی تا حرفه ای
ارسال شده توسط iman4web در مورخه : جمعه، 25 مرداد ماه ، 1387

تالار گفتمان جستجو

دانلود سنتر طراحان وب ایران
تعداد فایل ها: 11
تعداد شاخه ها: 11
جمع کل دانلودها: 130


 جدیدترین فایلها 
 1: دیتاشیت فارسی آی سی میکرو atmega32 (2)
[اضافه شده در: 26-Sep-2008]

 2: دیتاشیت فارسی آی سی Atmega48,88,168 (0)
[اضافه شده در: 26-Sep-2008]

 3: دیتاشیت فارسی Atmega8 (2)
[اضافه شده در: 26-Sep-2008]

 4: Bandwidth Meter Pro v2.6 (1)
[اضافه شده در: 18-Sep-2008]

 5: PHPNukeToolsVer3 (14)
[اضافه شده در: 14-Sep-2008]

 6: راهنمای فارسی سیستم مدیریت آگهی (6)
[اضافه شده در: 30-Aug-2008]

 7: block-Who-is-Where (6)
[اضافه شده در: 16-Jul-2008]

 8: Adobe Reader 8.1.1 for Windows XP SP2 / Vista (0)
[اضافه شده در: 06-Jan-2008]

 9: کرک آنتی ویروس Nod32 ver3.0.566 (44)
[اضافه شده در: 27-Dec-2007]

 10: ياهو مسنجر جديد ورژن 9 (21)
[اضافه شده در: 20-Dec-2007]


 آخرین بروزرسانی 

 بهترین دانلودی ها 
 1: کرک آنتی ویروس Nod32 ver3.0.566
[دانلود شده: 44 بار]

 2: 9 کلیپ بسیار جالب با فرمت 3GP مخصوص گوشیهای موبایل
[دانلود شده: 34 بار]

 3: ياهو مسنجر جديد ورژن 9
[دانلود شده: 21 بار]

 4: PHPNukeToolsVer3
[دانلود شده: 14 بار]

 5: راهنمای فارسی سیستم مدیریت آگهی
[دانلود شده: 6 بار]

 6: block-Who-is-Where
[دانلود شده: 6 بار]

 7: دیتاشیت فارسی Atmega8
[دانلود شده: 2 بار]

 8: دیتاشیت فارسی آی سی میکرو atmega32
[دانلود شده: 2 بار]

 9: Bandwidth Meter Pro v2.6
[دانلود شده: 1 بار]

 10: Adobe Reader 8.1.1 for Windows XP SP2 / Vista
[دانلود شده: 0 بار]



دریافت برنامه



هاست و دامنه


 
Iranwebco.com :: نمايش موضوعات - ترفندهای .htaccess

`

ترفندهای .htaccess

 

ارسال موضوع جديد  پاسخ به اين موضوع    

   Iranwebco.com صفحه اول انجمن -> برنامه نويسي

نمايش موضوع قبلي :: نمايش موضوع بعدي  
نويسنده پيغام

iman4web
مدیر سایت
مدیر سایت

وضعيت: آفلاين
16 آذر ماه ، 1386
تعداد ارسالها: 162
محل سكونت: تهران

ارسالارسال شده در: جمعه، 25 مرداد ماه ، 1387 12:49:44    موضوع مطلب: ترفندهای .htaccess پاسخ همراه با اعلان

فايل .htaccess يا Distributed Configuration Files در واقع فايلهاي مخصوص كنترل آپاچي هست مکان خاصی ندارند روی هر شاخه و زیر شاخه تاثیر میزاره در واقع در کنار فایل های معمولی مثل php ,html قرار میگیره یعنی کاملا در دسترس هستند نام این فایل ها .htaccess هست یعنی صرفا همین -البته میشه یه سری تنظیمات رو دستکاری کرد و نام رو تغییر داد- اين فايلها از تگهاي مخصوص آپاچي استفاده ميكنن البته cgi script هم مي پذيرن

کاربردها :

كاربرد اول- تغيير صفحات خطا

برای نمایش صفحات خطا مثل 404 يا 500 و ... میتونید صفحات دلخواه خودتون رو طراحي و به اين طريق نمایش بدید
مسلما خیلی حرفه ای هست وب سایت هایی که برای کوچکترین موارد پیش بینی صورت بگیره

كد:


ErrorDocument 404 /404.html
ErrorDocument 500 /500.html


كاربرد دوم- نمایش پسوند دلخواه صفحات (add mime type)

يك راه امنيتي كه من واقعا پيشنهاد ميكنم واسه حفاظت از اسكريپت هاي php شما اينه كه اونا php نباشن !! بله يعني مثلا asp يا jsp باشن اينطوري یه مقدار مطلب پیچیده میشه برای تشخیص


كد:

AddType application/x-httpd-php .asp .jsp

Addtype ميگه كه ما ميخوايم يه فرمت جديد بشناسونيم بعد نوع اون فايلهاي خاص با فرمت دلخواه رو ميگيم مثلا image/png يا text/css بعد ميگيم كه چه فرمتي رو از اين به بعد به عنوان نوعي كه گفتيم بشناس
اما فرض كنيد ميخوايد از shtml , ssl در سايتتون استفاده كنيد و نياز به شناساندن اين فرمتها به آپاچي داريد :

كد:

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

__________________
گزارش پست خلاف Thanks پاسخ با نقل قول Multi-Quote This Message ارسال پاسخ سريع به اين پيغام
Mohammad
نمايش مشخصات عمومي
ارسال يك پيام شخصي به Mohammad
وب سايت Mohammad
يافتن پستهاي بيشتر Mohammad
افزودن Mohammad به ليست دوستان



قدیمی 07-18-2008, 01:28 PM #2
Mohammad
Administrator

آواتار Mohammad

Mohammad آنلاین است
تاريخ عضويت: May 2008
محل سكونت: Tabriz
پست ها: 520
Thanks: 214
Thanked 241 Times in 155 Posts
پرچم من:
ارسال پيغام Yahoo به Mohammad

پيش فرض
كاربرد سوم- redirect ریدایرکت


كد:

Redirect /Dirold/test.html http://site.com/DirNew/new.html

توضيح: در اينجا مرورگري كه درخوست فايل test.html رو در شاخه dirold داشت بره به آدرس
http://site.com/DirNew/new.html

دوستانی که در زمینه SEO فعالیت دارند میدونند که این ریدایرکت چقدر موثره

كاربرد چهارم - IndexIgnore

بسیاری از هكرها بعد از نفوذ با browse كردن در دايركتوريهاي سايت شما و گشتن به دنبال فولدرها يا فايلها با پرميشن مطلوب كارشونو تكميل ميكنن و البته خيلي ها از اول از روش ديد زدن فولدرهايي كه حاوي موتور اسكريپت ها و اطلاعات با ارزشي هستن مثلا فايل config رو در بردارن به سايت نفوذ ميكنن
programer ها جهت جلوگيري از اين كار ميان و يه index.html خالي درست ميكنن اما با اين كد ميشه يه صفحه مربوط به خالي بودن فولدر رو نشون داد يعني هيچي تو اين شاخه نيست در حالي كه شاخه ميتونه پر فايل باشه ...

خیلی جالبه الان میتونم چندتا سایت پربازدید رو معرفی کنم که این مشکل رو دارند نکته خیلی جالبتر اینه که من مدتی پیش یک اسکریپت به دستم رسید داشتم ویرایشش میکردم و توابع اسمارتی رو بررسی میکردم که دیدم چندتا فایل کم هست یعنی چندتا صفحه نافص بود هرچقدذر نوشتم نتونستم اتصالات رو پیدا کنم تا اینکه برای تست رفتم وارد سایت تولید کننده این نرم افزار شدم از اونجایی که نسخه دمو روی سرور Run شده بود رفتم به دایرکتوری موردنظر با کمال تعجب دسترسی در پوشه تمپلیت مربوط به فایل های TPL باز بود منم با کمال لطف فایل های موردنظر رو برداشتم به همین راحتی

شاید در ظاهر استفاده از این طرفند خیلی پیش پا افتاده باشه اما میدونم خیلی از افراد به آسونی از کنارش میگذرند


كد:

IndexIgnore *

- اگه مثلا خواستيد فقط يه نوع فايل محافظت شه مثلا فقط فايلهاي pdf مينويسييد :


كد:

IndexIgnore application/pdf

_________________
مديريت سايت طراحان وب ایران
2335943 0912
Iranwebco.com
Iranwebco.net
Iranwebco.ir

بازگشت به بالا

رويت مشخصات كاربر ارسال پيغام شخصي ارسال ايميل بازديد از سايت ارسال كننده مطلب شناسه Yahoo

iman4web
مدیر سایت
مدیر سایت

وضعيت: آفلاين
16 آذر ماه ، 1386
تعداد ارسالها: 162
محل سكونت: تهران

ارسالارسال شده در: جمعه، 25 مرداد ماه ، 1387 12:50:17    موضوع مطلب: پاسخ همراه با اعلان

كاربرد پنجم - از index.php يا index.html خسته نشديد؟

با اين كد هم ميشه به وب سرور امر كرد كه كدام فايل به عنوان صفحه نخست نمایش داده بشه


كد:

DirectoryIndex homearea.php
homearea.php رو به هر فايلي با هر نامي تغيير بديد.
- DirectoryIndex يه فاصله و بعد نام فايل با هر فرمتي


كاربرد ششم - DefaultCharset

بسیاری از مشکلات دوستان نمایش انکودینگ صفحات اینترنتی هست با دستور زیر میتونید آپاچی رو مقید کنید تا Charset موردنظر شما رو ایجاد کنه


كد:

AddDefaultCharset utf-8

كاربرد هفتم - deny from all

جهت حفاظت فایل های باز ارزش ولي محافظت نميشن ( مثلا mt-config.cgi ) اين كد ميگه كه هيچ مرورگر ي نتونه سورس اينها رو ببينه

كد:

<Directory>
Order Deny,Allow
Deny from All
</Directory>

البته میشه این دسترسی رو فقط واسه یه آی پی محدود کرد


كد:

order allow,deny
deny from 123.45.6.7
deny from 012.34.5.
allow from all

كاربرد هشتم -امنیت بیشتر


دو تا كد امنيتيه ديگه

كد:

<Limit>
</Limit>

کارش که مشخصه فکر کنم


كد:

<LimitExcept>
</LimitExcept>

شما به بومبرينگ اعتقاد داريد ؟ اين كد جلوي FSOCKOPEN رو میگیره
__________________

_________________
مديريت سايت طراحان وب ایران
2335943 0912
Iranwebco.com
Iranwebco.net
Iranwebco.ir

بازگشت به بالا

رويت مشخصات كاربر ارسال پيغام شخصي ارسال ايميل بازديد از سايت ارسال كننده مطلب شناسه Yahoo

iman4web
مدیر سایت
مدیر سایت

وضعيت: آفلاين
16 آذر ماه ، 1386
تعداد ارسالها: 162
محل سكونت: تهران

ارسالارسال شده در: جمعه، 25 مرداد ماه ، 1387 12:51:05    موضوع مطلب: پاسخ همراه با اعلان

كاربرد نهم - rewrite engine

اول از همه Apache RewriteEngine بايد در وب سرور شما فعال باشه .
اگه دسترسي داريد ميتونيد اين خط رو در httpd.conf اضافه كنيد :


كد:

LoadModule rewrite_module modules/mod_rewrite.so

اگرم بهش دسترسي نداريد اين كد هم شايد بتونه كار كنه بايد تو همون htaccess كپي كنيد


كد:

<IfDefine>
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule *****_module modules/libproxy.so
</IfDefine>


اين همون چيزيه كه واسه ساب دومين مجازي هم به كار ميبريم من يه مثال سادشو واستون ميزنم
فرض كنيد يه وبلاگ داشتيد با اين آدرس http://www.azarteam.com/mohammad
حالا بلاگتون آدرسش عوض شده به اين http://www.azarteam.com/blog
البته دقت داشته باشيد اين هيچ ربطي به redirct نداره
**این مورد رو دوستانی که به SEO وارد هستند میتونند متوجه بشن که ریدایرکت با ریرایت خیلی فرق داره از نظر نتیجه ای که در اینده برای ما در برخواهد داشت


كد:

RewriteEngine on
RewriteRule ^ehsan(/.*)?$ /knowhow$1 [R=permanent]

یکی از بهترین امکاناتی که اپاچی بهتون میده بهش mod_rewrite هستش که باعث میشه سایتتون خیلی تمیزتر بنظر بیاد و به عبارتی SEO بشه !!!
تو هرجایی که شما بخواید از mod_rewrite استفاده کنید نیاز دارید که کد

كد:

Options +FollowSymlinks
RewriteEngine on

رو در فایل تون قرار بدید
بزارید یک مثال بزنم , میخوایم تمام صفحات php رو تبدیل کنیم به html :


كد:

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

در دستور بالا ما گفتیم هر فایل php بود تبدیلش کن به .htm ولی این دلیل براین نیست که فرمت فایل عوض میشه نه!!! بلکه به هردو صورت دسترسی به فایل امکان پذیر هست برای مثال اگه یه فایل test.php داشته باشیم هم میتونیم با اسم test.htm بهش دسترسی پیدا کنیم و هم از test.php .
[nc] : این دستور یعنی No Case یا همون case-insensitive

فرض میکنیم اسم دومینمون رو عوض کردیم ولی فایل هامون همون قبلی ها هستن و میخوایم هرکسی تو دومین اولی یک فایل رو فراخوانی کرد ما همون فایل رو تو دومین دوم صدا بزنیم اینجور عمل میکنیم :



كد:

Options +FollowSymlinks
rewriteengine on
rewriterule ^(.+).htm$ http://clicksor.ir/$1.php [r=301,nc]

301 یعنی مستقیما ریدایرکت شده , دستور بالا زمانی خوبه که یه سایت قدیمی داریم حالا میخوایم update کنیم این کار باعث میشه موتورهای جستجوگر نتایج ما رو اتوماتیک آپدیت کنند

اینجا رو ببینید »


كد:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^myfiles/(.+)/(.+).zip download.php?section=$1&filename=$2 [nc]

بزارید ساده بگم اگه شما عبارت (.+) رو مساوی با 1$ فرض کنیم ( 1$=(.+) )ما میتونیم چندین بار از این عبارت استفاده کنیم به این صورت که بار اول که از (.+) استفاده میکنیم مساوی با 1$ میگیریم در دفعه دوم مساوی با 2$ میگیریم و همینطور الا اخر .
در مثال بالا برای مثال اگه ما یه فایل در مسیر


كد:

http://clicksor.ir/download.php?section=appz&filename=Siavash



داشته باشیم این لینک از ادرس زیر هم در دسترس خواهد بود :

كد:

http://clicksor.ir/myfiles/appz/Siavash.zip


مثال :


كد:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/([0-9]+)-([a-z]+) http://clicksor.ir/weblog/index.php?archive=$1-$2 [nc]

حالا اگه ادرس ارشیو وبلاگ ما بصورت :


كد:

http://clicksor.ir/weblog/index.php?archive=2007-sep


باشه تبدیل میشه به :


كد:

http://Persiandev.net/blog/2007-sep



با کمی Regular Expression میتونید ادرس هاتون رو خیلی حرفه ای تر کنید و زیباتر

راهنما دستورات :



كد:

. Any single character
[chars] یکی ار کاراکترها میتونه این باشه برای مثال [A]
[^chars] هیج یک از این کاراکتر ها نباشه برای مثال [^A]
text1|text2 همون کار or رو انجام میده

Quantifiers:
? میتونه یک کاراکتر باشه و یا هیچ کاراکتری
* هرچیزی میتونه باشه حتی اگه چیزی وجود نداشته باشه
+ حداقل یک کاراکتر وجود دارد

Grouping:
(text) برای ساختن گروه بکار میره

Anchors:
^ شروع
$ پایان

Escaping:
char برای مثال برای درنظر نگرفتن علائمی مثل [] یا . یا غیره هست در این مواقع به عنوان دستور در نظر نمیگیره
مثال

كد:

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^get(.*) /public/download/download.php$1

در مثال بالا ما گفتیم هر ادرسی که بعد از download.php قرار گرفت تبدیلش کنه به ادرس برای مثال
اگه ادرسمون اینجوری باشه :


كد:

http://clicksor.ir/downloads/download.php?myfile=Siavash.zip



تبدیل میشه به :


كد:

http://clicksor.ir/Get?myfile=Siavash.zip

در مثال بعدی میخوایم دسترسی به پوشه هارو بگیریم از کاربر

كد:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ deny.php [nc]

تو قسمت بالا اگه کاربر بخواد به هر نحوی وارد یه پوشه بشه ریدایرکت میشه به deny.php
بزارید در مثال بعدی کاری کنیم که فقط به فایل های خاصی دسترسی داشته باشه و بجز اون هر فایلی خواست باز کنه ارور بده :

كد:

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

تو دستور بالا ما گفتیم فقط به فایل هایCss Js و فایل file.php اجازه بده که توسط کاربر فراخوانی بشه در غیر اینصورت ریدایرکت کنش به پوشه /deny/ .


HotLinking مثال

كد:

Options +FollowSymlinks
# no hot-linking
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?clicksor\.ir/ [nc]
RewriteRule .*.(gif|jpg|png)$ http://clicksor.ir/red.jpg [nc]

خوب فکر نمیکنم زیاد لازم به توضیح باشه کد بالا هر درخواستی رو که برای لود کردن عکس با فرمت gif,jpg,png از یه سایت دیگه باشه عکس http://clicksor.ir/red.jpg نمایش داده میشه .

اضافه کردن WWW به ادرس سایت :
این کد این کار رو براتون میکنه :


كد:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^www.clicksor.ir [nc]
rewriterule ^(.*)$ http://clicksor.ir/$1 [r=301,nc]
در واقع یه نوع ریدایرکت هستش البته از نوع peremantly moved .

ترجمه سایت :

كد:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)-fr$ http://www.google.com/translate_c?hl=fr&sl=en&u=http://clicksor.ir/$1 [r,nc]
RewriteRule ^(.*)-de$ http://www.google.com/translate_c?hl=de&sl=en&u=http://clicksor.ir/$1 [r,nc]
RewriteRule ^(.*)-es$ http://www.google.com/translate_c?hl=es&sl=en&u=http://clicksor.ir/$1 [r,nc]
RewriteRule ^(.*)-it$ http://www.google.com/translate_c?hl=it&sl=en&u=http://clicksor.ir/$1 [r,nc]
RewriteRule ^(.*)-pt$ http://www.google.com/translate_c?hl=pt&sl=en&u=http://clicksor.ir/$1 [r,nc]

در کد بالا در صورتی که به اخر یک لینک یا ادرس یکی از کلمات de , -fr , -pr, -it- اضافه بشه توسط گوگل میتونید ترجمه کنید .
عوض کردن نوع لینک برای مثال نوع ادرس عکس :


كد:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^pictures/(.*) http://clicksor.ir/getpicture.php?$1 [r]

خاموش و روشن کردن رجیستر گلوبال جهت اینستال برخی از برنامه ها


كد:

php_flag register_globals on

_________________
مديريت سايت طراحان وب ایران
2335943 0912
Iranwebco.com
Iranwebco.net
Iranwebco.ir

بازگشت به بالا

رويت مشخصات كاربر ارسال پيغام شخصي ارسال ايميل بازديد از سايت ارسال كننده مطلب شناسه Yahoo

iman4web
مدیر سایت
مدیر سایت

وضعيت: آفلاين
16 آذر ماه ، 1386
تعداد ارسالها: 162
محل سكونت: تهران

ارسالارسال شده در: دوشنبه، 28 مرداد ماه ، 1387 00:19:11    موضوع مطلب: پاسخ همراه با اعلان

.htaccess Definition1 [ ^ ]

Apache server software provides distributed (i.e., directory-level) configuration via Hypertext Access files. These .htaccess files enable the localized fine-tuning of Apache’s universal system-configuration directives, which are defined in Apache’s main configuration file. The localized .htaccess directives must operate from within a file named .htaccess. The user must have appropriate file permissions to access and/or edit the .htaccess file. Further, .htaccess file permissions should never allow world write access — a secure permissions setting is “644”, which allows universal read access and user-only write access. Finally, .htaccess rules apply to the parent directory and all subdirectories. Thus to apply configuration rules to an entire website, place the .htaccess file in the root directory of the site.

Commenting .htaccess Code [ ^ ]

Comments are essential to maintaining control over any involved portion of code. Comments in .htaccess code are fashioned on a per-line basis, with each line of comments beginning with a pound sign #. Thus, comments spanning multiple lines in the .htaccess file require multiple pound signs. Further, due to the extremely volatile nature of htaccess voodoo, it is wise to include only alphanumeric characters (and perhaps a few dashes and underscores) in any .htaccess comments.

Important Notes for .htaccess Noobs [ ^ ]

As a configuration file, .htaccess is very powerful. Even the slightest syntax error (like a missing space) can result in severe server malfunction. Thus it is crucial to make backup copies of everything related to your site (including any original .htaccess files) before working with your Hypertext Access file(s). It is also important to check your entire website thoroughly after making any changes to your .htaccess file. If any errors or other problems are encountered, employ your backups immediately to restore original functionality.

Performance Issues [ ^ ]

.htaccess directives provide directory-level configuration without requiring access to Apache’s main server cofiguration file (httpd.conf). However, due to performance and security concerns, the main configuration file should always be used for server directives whenever possible. For example, when a server is configured to process .htaccess directives, Apache must search every directory within the domain and load any and all .htaccess files upon every document request. This results in increased page processing time and thus decreases performance. Such a performance hit may be unnoticeable for sites with light traffic, but becomes a more serious issue for more popular websites. Therefore, .htaccess files should only be used when the main server configuration file is inaccessible. See the “Performance Tricks” section of this article for more information.

Regex Character Definitions for htaccess2 [ ^ ]

#
the # instructs the server to ignore the line. used for including comments. each line of comments requires it’s own #. when including comments, it is good practice to use only letters, numbers, dashes, and underscores. this practice will help eliminate/avoid potential server parsing errors.
[F]
Forbidden: instructs the server to return a 403 Forbidden to the client.
[L]
Last rule: instructs the server to stop rewriting after the preceding directive is processed.
[N]
Next: instructs Apache to rerun the rewrite rule until all rewriting directives have been achieved.
[G]
Gone: instructs the server to deliver Gone (no longer exists) status message.
[P]
Proxy: instructs server to handle requests by mod_proxy
[C]
Chain: instructs server to chain the current rule with the previous rule.
[R]
Redirect: instructs Apache to issue a redirect, causing the browser to request the rewritten/modified URL.
[NC]
No Case: defines any associated argument as case-insensitive. i.e., "NC" = "No Case".
[PT]
Pass Through: instructs mod_rewrite to pass the rewritten URL back to Apache for further processing.
[OR]
Or: specifies a logical "or" that ties two expressions together such that either one proving true will cause the associated rule to be applied.
[NE]
No Escape: instructs the server to parse output without escaping characters.
[NS]
No Subrequest: instructs the server to skip the directive if internal sub-request.
[QSA]
Append Query String: directs server to add the query string to the end of the expression (URL).
[S=x]
Skip: instructs the server to skip the next "x" number of rules if a match is detected.
[E=variable:value]
Environmental Variable: instructs the server to set the environmental variable "variable" to "value".
[T=MIME-type]
Mime Type: declares the mime type of the target resource.
[]
specifies a character class, in which any character within the brackets will be a match. e.g., [xyz] will match either an x, y, or z.
[]+
character class in which any combination of items within the brackets will be a match. e.g., [xyz]+ will match any number of x’s, y’s, z’s, or any combination of these characters.
[^]
specifies not within a character class. e.g., [^xyz] will match any character that is neither x, y, nor z.
[a-z]
a dash (-) between two characters within a character class ([]) denotes the range of characters between them. e.g., [a-zA-Z] matches all lowercase and uppercase letters from a to z.
a{n}
specifies an exact number, n, of the preceding character. e.g., x{3} matches exactly three x’s.
a{n,}
specifies n or more of the preceding character. e.g., x{3,} matches three or more x’s.
a{n,m}
specifies a range of numbers, between n and m, of the preceding character. e.g., x{3,7} matches three, four, five, six, or seven x’s.
()
used to group characters together, thereby considering them as a single unit. e.g., (perishable)?press will match press, with or without the perishable prefix.
^
denotes the beginning of a regex (regex = regular expression) test string. i.e., begin argument with the proceeding character.
$
denotes the end of a regex (regex = regular expression) test string. i.e., end argument with the previous character.
?
declares as optional the preceding character. e.g., monzas? will match monza or monzas, while mon(za)? will match either mon or monza. i.e., x? matches zero or one of x.
!
declares negation. e.g., “!string” matches everything except “string”.
.
a dot (or period) indicates any single arbitrary character.
-
instructs “not to” rewrite the URL, as in “...domain.com.* - [F]”.
+
matches one or more of the preceding character. e.g., G+ matches one or more G’s, while "+" will match one or more characters of any kind.
*
matches zero or more of the preceding character. e.g., use “.*” as a wildcard.
|
declares a logical “or” operator. for example, (x|y) matches x or y.
\
escapes special characters ( ^ $ ! . * | ). e.g., use “\.” to indicate/escape a literal dot.
\.
indicates a literal dot (escaped).
/*
zero or more slashes.
.*
zero or more arbitrary characters.
^$
defines an empty string.
^.*$
the standard pattern for matching everything.
[^/.]
defines one character that is neither a slash nor a dot.
[^/.]+
defines any number of characters which contains neither slash nor dot.
http://
this is a literal statement — in this case, the literal character string, “http://”.
^domain.*
defines a string that begins with the term “domain”, which then may be proceeded by any number of any characters.
^domain\.com$
defines the exact string “domain.com”.
-d
tests if string is an existing directory
-f
tests if string is an existing file
-s
tests if file in test string has a non-zero value

_________________
مديريت سايت طراحان وب ایران
2335943 0912
Iranwebco.com
Iranwebco.net
Iranwebco.ir

بازگشت به بالا

رويت مشخصات كاربر ارسال پيغام شخصي ارسال ايميل بازديد از سايت ارسال كننده مطلب شناسه Yahoo

iman4web
مدیر سایت
مدیر سایت

وضعيت: آفلاين
16 آذر ماه ، 1386
تعداد ارسالها: 162
محل سكونت: تهران

ارسالارسال شده در: دوشنبه، 28 مرداد ماه ، 1387 00:19:47    موضوع مطلب: پاسخ همراه با اعلان

Redirection Header Codes [ ^ ]

* 301 - Moved Permanently
* 302 - Moved Temporarily
* 403 - Forbidden
* 404 - Not Found
* 410 - Gone

Essentials [ ^ ]

Commenting your htaccess Files [ ^ ]

It is an excellent idea to consistenly and logically comment your htaccess files. Any line in an htaccess file that begins with the pound sign ( # ) tells the server to ignore it. Multiple lines require multiple pounds and use letters/numbers/dash/underscore only:

# this is a comment
# each line must have its own pound sign
# use only alphanumeric characters along with dashes - and underscores _

Enable Basic Rewriting [ ^ ]

Certain servers may not have “mod_rewrite” enabled by default. To ensure mod_rewrite (basic rewriting) is enabled throughout your site, add the following line once to your site’s root htaccess file:

# enable basic rewriting
RewriteEngine on

Enable Symbolic Links [ ^ ]

Enable symbolic links (symlinks) by adding the following directive to the target directory’s htaccess file. Note: for the FollowSymLinks directive to function, AllowOverride Options privileges must be enabled from within the server configuration file (see proceeding paragraph for more information):

# enable symbolic links
Options +FollowSymLinks

Enable AllowOverride [ ^ ]

For directives that require AllowOverride in order to function, such as FollowSymLinks (see above paragraph), the following directive must be added to the server configuration file. For performance considerations, it is important to only enable AllowOverride in the specific directory or directories in which it is required. In the following code chunk, we are enabling the AllowOverride privs only in the specified directory (/www/replace/this/with/actual/directory). Refer to this section for more information about AllowOverride and performance enhancement:

# enable allowoverride privileges
<Directory>
AllowOverride Options
</Directory>

Rename the htaccess File [ ^ ]

Not every system enjoys the extension-only format of htaccess files. Fortunately, you can rename them to whatever you wish, granted the name is valid on your system. Note: This directive must be placed in the server-wide configuration file or it will not work:

# rename htaccess files
AccessFileName ht.access

Note: If you rename your htaccess files, remember to update any associated configuration settings. For example, if you are protecting your htaccess file via FilesMatch, remember to inform it of the renamed files:

# protect renamed htaccess files
<FilesMatch>
Order deny,allow
Deny from all
</FilesMatch>

Retain Rules Defined in httpd.conf [ ^ ]

Save yourself time and effort by defining replicate rules for multiple virtual hosts once and only once via your httpd.conf file. Then, simply instruct your target htaccess file(s) to inheret the httpd.conf rules by including this directive:

RewriteOptions Inherit

_________________
مديريت سايت طراحان وب ایران
2335943 0912
Iranwebco.com
Iranwebco.net
Iranwebco.ir

بازگشت به بالا

رويت مشخصات كاربر ارسال پيغام شخصي ارسال ايميل بازديد از سايت ارسال كننده مطلب شناسه Yahoo

iman4web
مدیر سایت
مدیر سایت

وضعيت: آفلاين
16 آذر ماه ، 1386
تعداد ارسالها: 162
محل سكونت: تهران

ارسالارسال شده در: دوشنبه، 28 مرداد ماه ، 1387 00:20:30    موضوع مطلب: پاسخ همراه با اعلان

Performance [ ^ ]

Improving Performance via AllowOverride [ ^ ]

Limit the extent to which htaccess files decrease performance by enabling AllowOverride only in required directories. For example, if AllowOverride is enabled throughout the entire site, the server must dig through every directory, searching for htaccess files that may not even exist. To prevent this, we disable the AllowOverride in the site’s root htaccess file and then enable AllowOverride only in required directories via the server config file (refer to this section for more information). Note: if you do not have access to your site’s server config file and also need AllowOverride privileges, do not use this directive:

# increase performance by disabling allowoverride
AllowOverride None

Improving Performance by Passing the Character Set [ ^ ]

Prevent certain 500 error displays by passing the default character set parameter before you get there. Note: replace the “utf-8” below with the charset that your site is using:

# pass the default character set
AddDefaultCharset utf-8

Improving Performance by Preserving Bandwidth [ ^ ]

To increase performance on PHP enabled servers, add the following directive:

# preserve bandwidth for PHP enabled servers
<ifmodule>
php_value zlib.output_compression 16386
</ifmodule>

Disable the Server Signature [ ^ ]

Here we are disabling the digital signature that would otherwise identify the server:

# disable the server signature
ServerSignature Off

Set the Server Timezone [ ^ ]

Here we are instructing the server to synchronize chronologically according to the time zone of some specified state:

# set the server timezone
SetEnv TZ America/Washington

Set the Email Address for the Server Administrator [ ^ ]

Here we are specifying the default email address for the server administrator:

# set the server administrator email
SetEnv SERVER_ADMIN default@domain.com

Improve Site Transfer Speed by Enabling File Caching [ ^ ]

The htaccess genius over at askapache.com explains how to dramatically impro