ورود

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : چگونه اجرای htaccess بر روی کل سرور؟



asrhosting
July 27th, 2012, 19:15
با سلام .
نیاز داریم تعدادی کد بر روی .htaccess کل سایت های روی سرور اجرا بشه.
آیا میشه از سرور ( root ) این دستور رو داد که کل سایت ها به علاوه اون htaccess که دارن محتویات ما هم بهشون اضافه بشه ؟

asrhosting
July 27th, 2012, 19:43
از دوستان کسی اطلاعی داره؟

asrhosting
July 27th, 2012, 22:13
؟؟؟؟؟؟؟؟
کسی جوابی نداره ؟

fara_server
July 28th, 2012, 14:11
با سلام.
یک اسکریپت پرل نوشتم که کاری که شما میخواهید رو انجام میده.
-----------
# اسکریپت رو در داخل یک فایل با پسوند 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);
}



البته توضیجات برای دوستانی بود که با پرل آشنایی ندارند ، شما استاد ما هستید.
یا حق:53:

asrhosting
July 28th, 2012, 18:31
با سلام.
یک اسکریپت پرل نوشتم که کاری که شما میخواهید رو انجام میده.
-----------
# اسکریپت رو در داخل یک فایل با پسوند 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);
}



البته توضیجات برای دوستانی بود که با پرل آشنایی ندارند ، شما استاد ما هستید.
یا حق:53:


سلام .
خیلی ممنون .
جناب فرقی نداره این فایل کجای سرور باشه ؟ مثلا home ? .
موقعی که دستور اخر رو بزنم روی همه سایت ها اعمال میشه ؟ مشکلی با htaccess اونها بوجود نمی یاره ؟
اگر سایت جدیدی اضافه بشه سیستم خودش اتوماتیک انجام میده یا باید دوباره مراحل اخر رو رفت ؟

fara_server
July 28th, 2012, 18:52
سلام .
خیلی ممنون .
جناب فرقی نداره این فایل کجای سرور باشه ؟ مثلا home ? .
موقعی که دستور اخر رو بزنم روی همه سایت ها اعمال میشه ؟ مشکلی با htaccess اونها بوجود نمی یاره ؟
اگر سایت جدیدی اضافه بشه سیستم خودش اتوماتیک انجام میده یا باید دوباره مراحل اخر رو رفت ؟
#نه فرقی نداره کجای سرور باشه ، پیشفرض در root ذخیره کنید و اجرا کنید .
#خیر مشکلی به وجود نمیاد اطلاعات به انتهای فایلهای htaccess. ، اپند میشه.
#خیر این اسکریپت ساده ای بود که بنا به درخواستی که مطرح کرده بودید نوشتم ، زیاد روش کار نکردم، انشاا.. اگه وقت شد بیشتر روش کار میکنم تا استفاده ازش راحتتر باشه ، اما فعلا با عرض پوزش نمیرسم...:53:

asrhosting
July 28th, 2012, 19:57
انجام دادم ولی ارور داد و ....

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.

fara_server
July 28th, 2012, 23:37
دقیقا کدی رو که در فایل fast.pl قرار دادید رو اینجا قرار بدید برسی کنم ، من روی CentOS تست کردم بدون هیچ مشکلی کار میکنه!
احتمالا مشکل از درج کد Htaccess هست که قصد افزودن اون به انتهای فایلها رو داشتید ، من با یک متن ساده تست کردم و به راحتی اعمال شد...

fara_server
July 29th, 2012, 01:21
برای راحتی بیشتر کمی تغییر توی اسکریپت ایجاد کردم که کدهای 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();
}

بازم اگر مشکلی بود اعلام کنید برسی کنم...
یا حق:53:

asrhosting
August 26th, 2012, 02:13
ممنون فرا جان .
فایل باید تو پوشه pwd باشه یا اون pwd برا چه چیز دیگه اس ؟
اگر بخواییم چند تا httaccess اجرا بشه باید چی کار کرد ؟

fara_server
August 28th, 2012, 20:18
اون pwd یک پوشه دلخواه هست که به مسیر فایل code.txt که شامل محتوای htaccess. ماست اشاره داره ، بنا به نیازتون میتونید اون مسیر رو تغییر بدید و در اسکریپت درج کنید.
سوال دومتون رو درست متوجه نشدم،اما هرکاری میشه انجام داد فقط نیاز به اعمال تغییر در اسکریپت هست :)