Ht access? PHP routers

I need to use this code in replit:

Adding just the htaccess file isnt working. Can someone help me add this or translate it to bare php?

Hi @blake18, welcome to the community!

Replit currently doesn’t support .htaccess files. You can vote on this feature request:

Ok but, looking at the code, is there another way to achieve what I need to do in PHP maybe?

I’m not sure, I don’t know PHP. Hopefully someone else can help you there.

I see I can access the vm via the shell but im not seeing nginx or apache in /etc

Where is the nginx rewrite conf file?

You can install nginx easily on a repl.

2 Likes

How? Im not seeing any directions via google. Just premade repls.

I do know how to install nginx normally. But my concern is disabling the old web server, whatever it is, and having replit use nginx instead.

Try this:

  1. Create a repl using the Blank Repl template.
  2. Run this:
# Download nginx
curl -LO https://nginx-build.youngnuggets.repl.co/nginx.tar.gz
# Extract the archive
tar xf nginx.tar.gz
# Make nginx behave correctly
echo 'daemon off;' >> nginx/conf/nginx.conf
  1. Set the run command to nginx/sbin/nginx -p nginx in .replit.
  2. Start the repl, you can reconfigure nginx by editing nginx/conf/nginx.conf.
2 Likes

Why couldnt I just sudo apt install nginx?

html/css/js repls don’t let you control the webserver, so just make a different type of repl.

3 Likes

I made a php one though

Because Replir only persists /home/runner/$REPL_SLUG, and the root filesystem is mounted read-only.
By the way, if something tells you to use sudo, it might work if you just remove sudo (but apt won’t work that way, though)

You can usually just install packages using Nix (which Replit sets up for you)

2 Likes

That one uses the PHP development web server, it doesn’t let you do much.

2 Likes

Is there no LAMP stack replit?

I’m not sure what that is, what is it?

Apache + PHP is what I mean

1 Like

You might be able to make Apache work, but I’ve never personally tried it.

2 Likes

pkgs.cowsay
pkgs.apache

This isnt working in the nix file.

2 Likes