私のウェブサイトでいくつかのphpコードを使用して問題が発生しています。
私のサイトは主に html と php を使用しています。すべてのページの上部に多数のスクリプト行を繰り返す代わりに、php の include ステートメントを使用しています。
<?php include('main.php'); ?>
私のサイトには、ローカルの WAMP サーバーがあり、html ファイルと php ファイルが混在しています。
すべてをローカルで実行すると、すべてが完全に正常に実行され、「include」ステートメントが機能します。
ただし、goDaddy でホストされている自分のサイトにすべてをアップロードすると、include ステートメントは .php ファイル内でのみ機能します。.html ファイル内で使用すると失敗します。何も含まれていないだけです。
これは .htaccess ファイルを使用することで解決できるという投稿を見たことがあります。現時点では、私のサイトにはありません。ルート ディレクトリにアップロードしようとしましたが、ページをクリックしたときに [名前を付けて保存] ダイアログ ボックスが表示されただけでした。
私の構文が間違っているか、これを解決するために間違った道をたどったと推測しています。
以下は、私の .htaccess ファイルの内容です。include ステートメントを .html ファイル内で動作させる方法についてのアイデアは素晴らしいでしょう。ありがとう。
#
# Server root folder www .htaccess
# This file provides server security limiting access to the localhost only.
# Comment next four lines to deactivate. (Allows external access)
#
# Order Deny,Allow
# Deny from all
# Allow from 127.0.0.1
# Allow from ::1
AddType application/x-httpd-php .html .php .htm
# To allow execution of cgi scripts in this directory uncomment next two lines.
# AddHandler cgi-script .pl .cgi
# Options +ExecCGI +FollowSymLinks
# Activate this section to use the Private Server Feature!
# Defaults: Username - root; Password - root
# Note AuthUserFile: File path is relative to server root
# To lock server, uncomment the next 4 lines. (A name and password is required)
#AuthName "Uniform Server - Server Access"
#AuthType Basic
#AuthUserFile ../../../htpasswd/www/.htpasswd
#Require valid-user