MAMP / Slim PHP still have 404 error - mamp

I'm using MAMP PRO and Slim PHP framework.
Here is my project structure :
htdocs
myapp
api
index.php
.htaccess
My .htaccess :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
If I try with Postman a GET request on :
localhost:8888/admin
I get a 404 and this error in apache logs :
[error] [client ::1] File does not exist: /Applications/MAMP/htdocs/admin
But with this :
localhost:8888/myapp/api/index.php/admin
It works...
I'd like to do my request on this url :
localhost:8888/admin
I've try many things... RewriteBase, configure VirtualHost, ...
Can you help me ?

In Apache configuration set your document root to /Applications/MAMP/htdocs/myapp/api.

Related

howto internally redirect HTTP status codes for certain file types

When looking at my web server's access & error logs I notice quite a few instances where attackers seem to be fishing for the existence of certain *.php files and I don't actually want to help them with a 404 status message! Rather I'd like to return some happy 200 status and some dummy content for whatever non existing *.php file some idiot hacker tries to call on my site.
Also I don't care to have my error log spammed with respective non-existing php access attempts, e.g.:
[Thu Apr 16 11:42:42.700317 2020] [proxy_fcgi:error] [pid 3318670] [client x.x.x.x:54236] AH01071: Got error 'Primary script unknown\n', i.e. I'd like to redirect before the server feels inclined to report that issue.
What I am looking for is some web server internal redirect for all non-existing *.php files that will respond as if there actually was a respective (dummy) file. My web server access is limited to Plesk and .htaccess so ideally I am looking for something that I can configure via .htaccess
Any suggestions?
seems that adding the below in .htaccess pretty much does what I am looking for by redirecting any non-existing *.php files to _404.php:
# use dummy file for all non-existing .php files
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} \.(php)$ [NC]
RewriteRule ^(.*)$ /_404.php [QSA,L]
</IfModule>

Redirection loop on OVH server

i have a domain on ovh, and so i uploaded all the file via FTP,
but when i want to redirect www.example.com to https://www.example.com/file12345.html it creates a sort of loop which makes i end up on https://www.example.com/file12345.html/file12345.html/file12345.html/file12345.html/file12345.html/file12345.html/file12345.html etc.
I have tried both using the ovh redirection rules and adding an .htaccess file in the root folder with the following code :
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ https://www.example.com/file12345.html$1 [R=301,L]
The problem remains the same. Do you have any solution to that ?

remove # from url gives 404 error angular5

The thing is I was trying to remove the # from the angular 5 application.
I was successful in doing so, the app is also working fine but the problem is the internal links are giving 404 error when I try to reload or refresh the page
for eg,
www.example.com (is working fine on reload and refresh).
----------but----------
www.example.com/jobs (gives 404 error on reload and refresh)
/jobs : is part of routing
Thanks for help in advance.
Create a .htaccess file inside your root folder (next the package.json file) and paste this code to its content:
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
Hope it helps! :)

REST API - Not Found Error

I am working on a Rest Api for my application. This is my application structure
api
-config
-modules
--v1
---controllers
---models
-runtime
-tests
-web
backend
common
console
environments
frontend
I tried runing the following url http://192.168.1.4/~user/urshow/api/modules/v1/web/users
I got a Not found Error. I do have a controller named Users inside controllers folder.
My .htaccess file is like this (which is inside urshow/api/web)
RewriteEngine on
RewriteBase /~user/urshow/api/modules/v1/web/
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
I found the solution. I had made some mistakes. First my .htaccess file was incorrect.
i had this line before RewriteBase /~user/urshow/api/modules/web/
i changed it to RewriteBase /~user/urshow/api/web/
also the url which i was trying was also wrong http://192.168.1.4/~user/urshow/api/web/movies/details
correct url is http://192.168.1.4/~user/urshow/api/web/v1/movies/details.
You haven't added the rest of the url to the redirect. Try using this on your last line;
RewriteRule ^(.*)$ index.php$1

Router slim not working

I'm trying to use the Slim FrameWork following documentation for the same, set up mod_rewrite and installed mcryp;
If I call http://localhost/slim/books got: Not Found
If I call http://localhost/frame/index.php?books works!
What could this be.
This happens for the slim and flight, but does not happen to Laravel.
Here my htaccess:
RewriteEngine On
RewriteCond% {REQUEST_FILENAME}!-F
RewriteRule ^ (. *) $ / Index.php [QSA]
I'm using:
Apache/2.4.10 (Ubuntu 04.14)
PHP Version 5.5.15RC1
Anyone know what it could be?
In your .htaccess file change Index.php to index.php.
create an .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
Case while running
To run file example myproj/file.php
$app->get('/',function() {
});
localhost/myproj/file.php
$app->get('/nam',function() {
});
localhost/myproj/file.php/nam
you can also use postman
https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en