Php page not opening

So my website data is on github and connected to Cloudflare, so whenever I go to the page, the php file downloads automatically, so it’s refusing to access the php file for no reason, even though I’m using the correct settings in my htaccess file.

RewriteEngine on
#remove extension html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

#remove extension php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

DirectoryIndex Phoenician.html

I am not aware if it’s possible to serve .php from GitHub repo :thinking:
GitHub Pages connected with the Cloudflare Pages only serve static content (HTML, CSS and JavaScript). GitHub Pages is a static site hosting service and doesn’t support server-side code such as PHP. The .htaccess file wouldn’t have an impact.

Your PHP code would have to be hosted somewhere else on a web server (LAMP/LEMP stack). GitHub is just a platform where you store your code and yes, GitHub does support storing PHP code if that’s the question. You can store the code and access it from anywhere in the World.

However, I am afraid you’ve fundamentally misunderstood how GitHub Pages works. Git is sort of the anti-CMS. It’s ideal for users without a lot of content, who like to edit the HTML/CSS/JS instead of spoon feed content to a system like Wix, Squarespace, or WordPress.

Except, you’re using GitHub/Cloudflare pages for static content, but now for some other reason while using Cloudflare, your domain is returning “download PHP file” instead of showing it from your web hosting? :thinking:

Otherwise, you could use cURL in your .php to parse and run the RAW code output of the file from GitHub repo on your local server.

1 Like

Yes when you try to open the page it downloads the php file lol i guess i have to find another free server i have no experience with php and the backend stuff :confused: thanks anyway man really appreciate

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.