我遵循一個「如何」的解釋,以便從.html文件執行PHP,但我無法讓它在我的.htaccess文件中工作。有沒有另一種解決方案?我如何讓PHP包含在html頁面中運行?
這是我在我的.htaccess文件中的代碼。
AddType application/x-httpd-php .html
我目前沒有html的中的任何一個我的HREF標記的建立,因爲我不慣於html的網頁地址欄內顯示。
當我嘗試將上述代碼放入我的.htaccess文件並導航到該網站時,我的瀏覽器提示我下載該頁面而不是導航到該頁面。最終,我試圖在我的html頁面上運行這個php include函數,而不是.php頁面。
我有一個鏈接我的索引頁中的代碼:
<li class="home-btn" style="border-bottom:5px solid #ff9b2e;"><a href="/"><img src="images/home.svg" width="37px" alt="3Elements Review, a literary journal based in Chicago, Illinois." border="none" id="home-btn"></a></li>
<li class="current" style="background-color:#313131;"><a href="current-journal" class="current">CURRENT JOURNAL<span class="sub-nav">Our latest and greatest!</span></a></li>
<li class="submit" style="background-color:#404040;"><a href="submit" class="current">SUBMIT<span class="sub-nav">Your writing</span></a></li>
<li class="guidelines" style="background-color:#505050;"><a href="submission-guidelines" class="current">SUBMISSION GUIDELINES<span class="sub-nav">Everything you need to know is here</span></a></li>
<li class="blog" style="background-color:#4b4b4b;"><a href="http://3elementsreview.blogspot.com" class="current">BLOG<span class="sub-nav">Just a blog</span></a></li>
<li class="past" style="background-color:#404040;"><a href="past-journals" class="current">PAST JOURNALS<span class="sub-nav">Browse our issue archives</span></a></li>
<li class="about" style="background-color:#313131;"><a href="about-3elements" class="current">ABOUT 3E<span class="sub-nav">What we're about</span></a></li>
這似乎從具體到GoDaddy的作品另一個線程這個答案。甚至沒有被接受的答案,但還有一個額外的評論。
Using .htaccess to make all .html pages to run as .php files?
Options +ExecCGI
AddType application/x-httpd-php .php .html
AddHandler x-httpd-php5 .php .html
你可能必須更新服務器的httpdconf文件,以允許在PHP文件與.html擴展名是什麼。您的服務器可能不允許在.htaccess文件中。爲什麼不將頁面更新爲'.php'擴展名,並將擴展名隱藏在.htaccess文件中? – timgavin
我一直試圖做到這一點,這兩個選擇之一。但那也沒用。根據建議,我早先修改了我的.htaccess文件。 –
我嘗試這樣做: RewriteEngine敘述在 的RewriteCond%{} REQUEST_FILENAME -d 的RewriteCond%{DOCUMENT_ROOT}/$ 1.PHP -f [NC] 重寫規則^(+?)(?:HTML)?$/$ 1.php [L,NC] –