0

我正在尝试通过 ssh 使用 .sh 脚本修改/触摸 .htaccess 文件。当前的代码是我所拥有的,但是由于语法不正确,我肯定会遇到错误。我假设必须在第 18 行正确配置撇号、引号或反斜杠。如果您看到我在哪里出错,请告诉我。

这是代码:

#!/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

这是错误:/touch.sh: line 19: nokeepalive: command not found

4

1 回答 1

0

脚本中的这一行用双引号引起来,从而关闭 echo 命令中的引号。您需要将回显引号更改为单引号或将该行周围的引号更改为单引号。如果我是你,我会选择第一个。

 SetEnvIf User-Agent ".*MSIE.*" \

**更新。以下 echo 命令对我来说很好。复制并粘贴它。

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]'
于 2012-10-25T16:06:23.087 回答