I’m trying to remove: "site.php"
from my url:s, which look like
"example.com/custom-foldername/site.php"
, so the url:s would look like "example.com/custom-foldername"
Currently it’s not working at all. Basically my site just doesn’t change the url. I know that the .htaccess
file is being read, because if i write junk code in it, it gives error 500.
Here is my current .htaccess
code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options -Indexes
RewriteRule ^site.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site.php [L]
</IfModule>
2
Answers
UPDATE: I solved this my myself while ago, but forgot to update
So, i found the solution and here's my current .htaccess file, if someone is ever having the same problem
When user "asks" for folder directory (example.com/cats) apache looks for "site.php or site.html" files inside it. (example.com/cats/site.php) If it finds either on of them it displays it to the user as (example.com/cats). If either file isn't found it gives normal "404 not found error"
The code you posted is a front-controller pattern – it rewrites every request for non-existent files to
/site.php
in the document root (not/custom-foldername/site.php
).And nor will a
RewriteRule
pattern like^site.php$
match a request like/custom-foldername
if the.htaccess
file is in the document root.From all your URLs? Is
site.php
present in all your URLs? So,site.php
is your front-controller?If
site.php
really is your front-controller then try something like the following instead:This rewrites everything that doesn’t map to a physical file or directory to
/custom-foldername/site.php
.