I’m trying to modify/touch a .htaccess file using a .sh script via ssh. The current code is what I have, but i’m getting errors I’m sure due to improper syntax. I’m assuming an apostrophe, Quote or backslash has to be configured properly on line 18. Let me know if you see where I’m going wrong with this.
here’s the code:
#!/bin/sh
touch /home/hessyste/public_html/.htaccess
echo "<IfModule mod_php5.c>
php_value upload_max_filesize 30M
php_value post_max_size 30M
php_value max_execution_time 1200
php_value max_input_time 1200
php_value display_errors On
php_value error_reporting E_ALL
</IfModule>
LimitRequestBody 31457280
<IfModule mod_setenvif.c>
<IfDefine SSL>
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
</IfDefine>
</IfModule>
RewriteEngine On
RewriteBase /${dir}
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteCond %{REQUEST_URI} !^/cpanel
RewriteRule ^([A-Z0-9\-\_]+)/?$ index.php?ref_name=$1 [NC,L]
RewriteRule contact_page contact_us.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).php$ index.php [NC,L]" > /home/hessyste/public_html/.htaccess
here’s the error:
/touch.sh: line 19: nokeepalive: command not found
This line in your script is wrapped in double quotes, thus closing the quotes on your echo command. You need to either change the echo quotes to single quotes or the quotes around that line to single quotes. I’d go with the first one if I was you.
**Update. The following echo command works for me just fine. Copy and paste that.