Closed cdchn1989 closed 1 year ago
Should be the content of the .htaccess file not be like this (!!! linebreaks !!!:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Not sure about that file, never used "that" construct - personally I use more something like following (with non-docker instances):
RewriteEngine On
# Store the current location in an environment variable CWD to use
# mod_rewrite in .htaccess files without knowing the RewriteBase
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=CWD:%2]
# ... additional rules, like block source controle folders etc.
# for security reason
# Final rewrite to the /index.php script (with proper subfolder handling)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
I would guess you recieve the "Internal Server Error" because of the malformed .htaccess. Your "php native" does not use the .htaccess, thus not a compare here.
Personally never used the one of the images with a webserver - if it is not the malformed .htaccess, you should check the server logs what they tell you.
What happens if you call the "/index.php" file directly ? is php executed at all ?
I would say, you are hitting casual apache / fpm errors - thus out of the scope of this issue tracker (however I'm not a official, so don't take that for granted).
Should be the content of the .htaccess file not be like this (!!! linebreaks !!!:
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [QSA,L]
Not sure about that file, never used "that" construct - personally I use more something like following (with non-docker instances):
RewriteEngine On # Store the current location in an environment variable CWD to use # mod_rewrite in .htaccess files without knowing the RewriteBase RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$ RewriteRule ^.*$ - [E=CWD:%2] # ... additional rules, like block source controle folders etc. # for security reason # Final rewrite to the /index.php script (with proper subfolder handling) RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
I would guess you recieve the "Internal Server Error" because of the malformed .htaccess. Your "php native" does not use the .htaccess, thus not a compare here.
Personally never used the one of the images with a webserver - if it is not the malformed .htaccess, you should check the server logs what they tell you.
What happens if you call the "/index.php" file directly ? is php executed at all ?
I would say, you are hitting casual apache / fpm errors - thus out of the scope of this issue tracker (however I'm not a official, so don't take that for granted).
Hello sbuerk thank you so much for your reply, Actually this line breaks was github mistake, I will try storing the current location ans unsing this in .htaccess, when a run index.php everything works pretty well and fine. My issue is just whit these "sub routes" and I guess you are rigth, Let me try and I gonna tell was happened. Is like instead of get route is specting a folder or something like that (Actually I will try just to see what happend).
Regards.
@sbuerk I putted your recomendations on .htaccess and this is what I'm getting is an error with some apache commands. With mime I got the same error. I will try to fix this.
Apparently I need to install rewrite module.
@cdchn1989 Reading the log, it indicates that the rewrite module is not loaded, yes. That error should have been in the log with your htaccess too.
I guess, albit not tested, that you need a Dockerfile e.g. like following:
FROM php:8.1-apache
# activate needed apache modules
RUN a2enmod rewrite
or at least add the RUN in your Dockerfile. the "FROM" is just example, use the image you are using right now instead.
@cdchn1989 Reading the log, it indicates that the rewrite module is not loaded, yes. That error should have been in the log with your htaccess too.
I guess, albit not tested, that you need a Dockerfile e.g. like following:
FROM php:8.1-apache # activate needed apache modules RUN a2enmod rewrite
or at least add the RUN in your Dockerfile. the "FROM" is just example, use the image you are using right now instead.
Hello thank you so much for your reply and this is what I did and works fine, my issue now is with railway docker no running properly but this is another topic, so again thank you so much.
Regards.
Hello guys, firt off all is a pleasure for my to put an issue in this repository, So lets go to the issue, recently I'm trying to migrate my old PHP apps deployed on Cpanel the platform which has been choosen to do this migration was Railway app, actually railway app is pretty cool and easy to use. So What is the problem? , In some services in that case I'm using PHP Slim Micro framework, So I've updated my framework fix some stuff (line codes) and test in my local enviroment, of course I tested my API with (PHP 8.2) php -S locahost:8001, in that case works fine, To work with railway app I have to options: 1. Deploy native php (Nix container) or 2 deploy docker, So I've decided to use docker, but I have an issue PHP Slim needs a .htcaccess file to work fine over apache, for that reason to run my container I use php:8.2-apache, So whats is my issue when I put the .htaccess file all my API routes doesn't work.
My docker file is this :
My .htaccess have this:
My index.php have this:
My scafolding is this:
Yes the index.php file and .htaccess must to be in the same folder.
So when I run my container with the htaccess file I allways get the error 404 in any single route.
I have attached two images of localhost:8000 (docker instance running) and localhost:8001 (php "native" run), My cuestion is There is any rigth way to put an own .htaccess file into this container.
port 8000 docker instance runnign![docker-php](https://user-images.githubusercontent.com/22404761/219101701-5ecf1e3b-17f0-4377-825f-c7df2cd99489.png)
port 8001 native instance running![native-php](https://user-images.githubusercontent.com/22404761/219101706-542460e5-064d-4bdd-ad67-8ad597c4e40c.png)