Htaccess doesn't seem to work


i have an htaccess file in htdocs with the following

RewriteEngine On
RewriteRule ^(.+)$ /index.html?planta=$1 [L,R=301]

objective is that so when i go to
i get redirected to

however i get redirected to a 404 error page

i’m new to htaccess and infinityfree so i can’t figure out what i’m doing wrong

It seems like you want to rewrite a query string as a path. A quick Google search brings me to this:

i’m still confused about how it works but i changed it to this

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*?)/?$ /index.html?planta=$1 [L]

using the example in the link you showed
and i’m still getting the same problem
going to leads me to a 404 error page
i honestly don’t think the problem is in the code, everything seems to be typed correctly and makes sense, but somehow doesn’t work
i could be wrong tough

U can use a 301 redirect.

I did, nothing changes, still 404.


RewriteEngine On
RewriteRule ^/?([0-9]+)/?$ /index.html?planta=$1 [L]

More solutions outlined here:

1 Like

None of them seem to work, in any way
Just tried 3 different solutions from there, all of them lead to a 404 page
That’s why i don’t think the problem is in the code
I might be doing something else wrong
Also i’ve tried this earlier in the day and it did seem to work sometimes
Just now it doesn’t anymore

Just to confirm, is the .htaccess in the htdocs folder?

1 Like

So, Do you want to use instead of ?

If Yes

1.Write your code in any code editor (VSC)
2.Create a file in Infinity Free as example (don’t include the html version)
3.Paste the Code in the File
4.Your Page is Live

This will work with HTML, CSS, JS, PHP

Sorry if I was wrong !

Judging by your desired situation, then from the top of my head, I think this is the .htaccess code you need:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.html?planta=$1 [L,R=301]

So your original code seems like a good solution.

I checked your account and I think I see why your previous code gave a 404 error: the code is placed in a file called htaccess, but it should be called .htaccess. The dot at the start is really important, and the file needs to be named exactly that or it won’t be picked up.


Thank you admin, that fixed it!
I didn’t notice the dot was missing
Now it works how i wanted :smiley:


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