با سلام .
نیاز داریم تعدادی کد بر روی .htaccess کل سایت های روی سرور اجرا بشه.
آیا میشه از سرور ( root ) این دستور رو داد که کل سایت ها به علاوه اون htaccess که دارن محتویات ما هم بهشون اضافه بشه ؟
با سلام .
نیاز داریم تعدادی کد بر روی .htaccess کل سایت های روی سرور اجرا بشه.
آیا میشه از سرور ( root ) این دستور رو داد که کل سایت ها به علاوه اون htaccess که دارن محتویات ما هم بهشون اضافه بشه ؟
میزبانی هاست لینوکس و ویندوز | نمایندگی دایرکت ادمین ، سی پنل ، پلسک روی سرورهای ایران
ارائه سرور مجازی از ایران با پهنای باند نامحدود و لایسنس رایگان دایرکت ادمین ، سی پنل ، پلسک
از دوستان کسی اطلاعی داره؟
میزبانی هاست لینوکس و ویندوز | نمایندگی دایرکت ادمین ، سی پنل ، پلسک روی سرورهای ایران
ارائه سرور مجازی از ایران با پهنای باند نامحدود و لایسنس رایگان دایرکت ادمین ، سی پنل ، پلسک
؟؟؟؟؟؟؟؟
کسی جوابی نداره ؟
میزبانی هاست لینوکس و ویندوز | نمایندگی دایرکت ادمین ، سی پنل ، پلسک روی سرورهای ایران
ارائه سرور مجازی از ایران با پهنای باند نامحدود و لایسنس رایگان دایرکت ادمین ، سی پنل ، پلسک
با سلام.
یک اسکریپت پرل نوشتم که کاری که شما میخواهید رو انجام میده.
-----------
# اسکریپت رو در داخل یک فایل با پسوند pl. در سرور ذخیره کنید.
# کد مورد نظرتون رو که در نظر دارید به htaccess. اضافه کنید درداخل کد و به جای : INSERT CODE HERE قرار بدید.
#برای اجرا از طریق ترمینال : Perl script.pl
البته توضیجات برای دوستانی بود که با پرل آشنایی ندارند ، شما استاد ما هستید.کد:#!/usr/bin/env perl ######################## #C0ded by : fara_server ######################## use strict; use warnings; my $locate = "find -name '.htaccess'"; my @path = `$locate`; chomp @path; foreach my $result (@path) { open FILE,">> $result"; print FILE"INSERT CODE HERE!"; close(FILE); }
یا حق![]()
کانفیگ،امنیت بخشی و راه اندازی انواع سروها با هزینه مناسب | طراحی و برنامه نویسی تحت وب | جهت درخواست از اینجا اقدام نمایید.
--==--==--==--
!Linux Geek
میزبانی هاست لینوکس و ویندوز | نمایندگی دایرکت ادمین ، سی پنل ، پلسک روی سرورهای ایران
ارائه سرور مجازی از ایران با پهنای باند نامحدود و لایسنس رایگان دایرکت ادمین ، سی پنل ، پلسک
#نه فرقی نداره کجای سرور باشه ، پیشفرض در root ذخیره کنید و اجرا کنید .
#خیر مشکلی به وجود نمیاد اطلاعات به انتهای فایلهای htaccess. ، اپند میشه.
#خیر این اسکریپت ساده ای بود که بنا به درخواستی که مطرح کرده بودید نوشتم ، زیاد روش کار نکردم، انشاا.. اگه وقت شد بیشتر روش کار میکنم تا استفاده ازش راحتتر باشه ، اما فعلا با عرض پوزش نمیرسم...![]()
کانفیگ،امنیت بخشی و راه اندازی انواع سروها با هزینه مناسب | طراحی و برنامه نویسی تحت وب | جهت درخواست از اینجا اقدام نمایید.
--==--==--==--
!Linux Geek
انجام دادم ولی ارور داد و ....
Bareword found where operator expected at fast.pl line 19, near "ExpiresByType image/x-icon "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 19, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 20, near "ExpiresByType text/css ""
(Might be a runaway multi-line "" string starting on line 19)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 20, near "ExpiresByType text/css "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 20, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 21, near "ExpiresByType text/javascript ""
(Might be a runaway multi-line "" string starting on line 20)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 21, near "ExpiresByType text/javascript "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 21, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 22, near "ExpiresByType application/x-javascript ""
(Might be a runaway multi-line "" string starting on line 21)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 22, near "ExpiresByType application/x-javascript "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 22, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 23, near "Header unset Last-Modified""
(Might be a runaway multi-line "" string starting on line 22)
(Missing semicolon on previous line?)
syntax error at fast.pl line 14, near "ExpiresDefault "access plus "
Execution of fast.pl aborted due to compilation errors.
root@linux [/home]# perl fast.pl
Bareword found where operator expected at fast.pl line 14, near "ExpiresDefault "access"
(Might be a runaway multi-line "" string starting on line 11)
(Do you need to predeclare ExpiresDefault?)
Bareword found where operator expected at fast.pl line 14, near "1 year"
(Missing operator before year?)
String found where operator expected at fast.pl line 15, near "ExpiresByType text/html ""
(Might be a runaway multi-line "" string starting on line 14)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 15, near "ExpiresByType text/html "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 15, near "1 second"
(Missing operator before second?)
String found where operator expected at fast.pl line 16, near "ExpiresByType image/gif ""
(Might be a runaway multi-line "" string starting on line 15)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 16, near "ExpiresByType image/gif "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 16, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 17, near "ExpiresByType image/jpeg ""
(Might be a runaway multi-line "" string starting on line 16)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 17, near "ExpiresByType image/jpeg "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 17, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 18, near "ExpiresByType image/png ""
(Might be a runaway multi-line "" string starting on line 17)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 18, near "ExpiresByType image/png "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 18, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 19, near "ExpiresByType image/x-icon ""
(Might be a runaway multi-line "" string starting on line 18)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 19, near "ExpiresByType image/x-icon "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 19, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 20, near "ExpiresByType text/css ""
(Might be a runaway multi-line "" string starting on line 19)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 20, near "ExpiresByType text/css "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 20, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 21, near "ExpiresByType text/javascript ""
(Might be a runaway multi-line "" string starting on line 20)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 21, near "ExpiresByType text/javascript "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 21, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 22, near "ExpiresByType application/x-javascript ""
(Might be a runaway multi-line "" string starting on line 21)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 22, near "ExpiresByType application/x-javascript "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 22, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 23, near "Header unset Last-Modified""
(Might be a runaway multi-line "" string starting on line 22)
(Missing semicolon on previous line?)
syntax error at fast.pl line 14, near "ExpiresDefault "access plus "
Execution of fast.pl aborted due to compilation errors.
root@linux [/home]# nano fast.pl
root@linux [/home]# perl fast.pl
Bareword found where operator expected at fast.pl line 16, near "ExpiresDefault "access"
(Might be a runaway multi-line "" string starting on line 11)
(Do you need to predeclare ExpiresDefault?)
Bareword found where operator expected at fast.pl line 16, near "1 year"
(Missing operator before year?)
String found where operator expected at fast.pl line 17, near "ExpiresByType text/html ""
(Might be a runaway multi-line "" string starting on line 16)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 17, near "ExpiresByType text/html "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 17, near "1 second"
(Missing operator before second?)
String found where operator expected at fast.pl line 18, near "ExpiresByType image/gif ""
(Might be a runaway multi-line "" string starting on line 17)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 18, near "ExpiresByType image/gif "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 18, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 19, near "ExpiresByType image/jpeg ""
(Might be a runaway multi-line "" string starting on line 18)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 19, near "ExpiresByType image/jpeg "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 19, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 20, near "ExpiresByType image/png ""
(Might be a runaway multi-line "" string starting on line 19)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 20, near "ExpiresByType image/png "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 20, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 21, near "ExpiresByType image/x-icon ""
(Might be a runaway multi-line "" string starting on line 20)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 21, near "ExpiresByType image/x-icon "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 21, near "2592000 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 22, near "ExpiresByType text/css ""
(Might be a runaway multi-line "" string starting on line 21)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 22, near "ExpiresByType text/css "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 22, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 23, near "ExpiresByType text/javascript ""
(Might be a runaway multi-line "" string starting on line 22)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 23, near "ExpiresByType text/javascript "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 23, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 24, near "ExpiresByType application/x-javascript ""
(Might be a runaway multi-line "" string starting on line 23)
(Missing semicolon on previous line?)
Bareword found where operator expected at fast.pl line 24, near "ExpiresByType application/x-javascript "access"
(Do you need to predeclare ExpiresByType?)
Bareword found where operator expected at fast.pl line 24, near "604800 seconds"
(Missing operator before seconds?)
String found where operator expected at fast.pl line 25, near "Header unset Last-Modified""
(Might be a runaway multi-line "" string starting on line 24)
(Missing semicolon on previous line?)
syntax error at fast.pl line 16, near "ExpiresDefault "access plus "
Execution of fast.pl aborted due to compilation errors.
میزبانی هاست لینوکس و ویندوز | نمایندگی دایرکت ادمین ، سی پنل ، پلسک روی سرورهای ایران
ارائه سرور مجازی از ایران با پهنای باند نامحدود و لایسنس رایگان دایرکت ادمین ، سی پنل ، پلسک
دقیقا کدی رو که در فایل fast.pl قرار دادید رو اینجا قرار بدید برسی کنم ، من روی CentOS تست کردم بدون هیچ مشکلی کار میکنه!
احتمالا مشکل از درج کد Htaccess هست که قصد افزودن اون به انتهای فایلها رو داشتید ، من با یک متن ساده تست کردم و به راحتی اعمال شد...
کانفیگ،امنیت بخشی و راه اندازی انواع سروها با هزینه مناسب | طراحی و برنامه نویسی تحت وب | جهت درخواست از اینجا اقدام نمایید.
--==--==--==--
!Linux Geek
برای راحتی بیشتر کمی تغییر توی اسکریپت ایجاد کردم که کدهای htaccess رو از فایلی در کنارش (code.txt) میخونه.
کافیه که کد مورد نظر رو درون فایل code.txt ذخیره کنید و بعد از اون اسکریپت رو اجرا کنید...
%تست شده%
بازم اگر مشکلی بود اعلام کنید برسی کنم...کد:#!/usr/bin/env perl######################## #C0ded by : fara_server ######################## use strict; use warnings; my $htcode; my $sourcefile="pwd/code.txt"; my $locate = "find -name '.htaccess'"; my @path = `$locate`; chomp @path; if(@path && -e $sourcefile){ open SFILE,"code.txt"; my @output=<SFILE>; foreach my $result (@path) { open FILE,">> $result"; foreach $htcode(@output) { print FILE $htcode; } } close(SFILE); close(FILE); print "\n \r DONE!\n"; }else{ print "Error - FILE NOT FOUND - somthing is wrong!\r\n"; exit(); }
یا حق![]()
کانفیگ،امنیت بخشی و راه اندازی انواع سروها با هزینه مناسب | طراحی و برنامه نویسی تحت وب | جهت درخواست از اینجا اقدام نمایید.
--==--==--==--
!Linux Geek
ممنون فرا جان .
فایل باید تو پوشه pwd باشه یا اون pwd برا چه چیز دیگه اس ؟
اگر بخواییم چند تا httaccess اجرا بشه باید چی کار کرد ؟
میزبانی هاست لینوکس و ویندوز | نمایندگی دایرکت ادمین ، سی پنل ، پلسک روی سرورهای ایران
ارائه سرور مجازی از ایران با پهنای باند نامحدود و لایسنس رایگان دایرکت ادمین ، سی پنل ، پلسک
در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)