Slim PHP: 404 not found - php

Slim PHP keeps on giving me a 404 Not Found, whenever accessing either the index.php itself, or any of the REST services (e.g. index.php/MyService)
I suspect that my problem is related to my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Directory structure:
My Slim index.php is located under
/var/www/api/v1/index.php
My apache2.conf:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I can execute any other PHP script just fine (e.g. /api/v1/test.php)

Related

centos wordpress the requested URL was not found on this server,

I am trying to host my wordpress project in centos remotely, i have hosted it on /var/www/html and gave permission 777 for all sub folders and files, and changes
and in .httpd file i have changed to all
<Directory />
AllowOverride All
# Require all denied
</Directory>
and
<Directory "/var/www">
AllowOverride All
# Allow open access:
# Require all granted
</Directory>
also in
<Directory "/var/www/html">
AllowOverride All
</Directory>
have changed
<Directory "/var/www/cgi-bin">
AllowOverride All
Options None
Require all granted
</Directory>
but not use the i am getting same internal server error, and The requested URL /l was not found on this server, but i can able to access backend of wordpress wp-admin what would be the problem then?
Adding this in .htaccess solved the problem
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
I think the best way is check apache error log.

.htaccess ErrorDocument 404 not redirecting

I have tried to create a custom page for the 404 errors to go to, these are the settings in my apache2.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/html>
options Index FollowSymLinks
AllowOverride All
Require all granted
</Directory>
and this is my code in the .htaccess file
RewriteEngine On # Turn on the rewriting engine
ErrorDocument 404 /404.php
RewriteRule ^ls/(\w+)/?$ Pages/misc/profile.php?ss=$1 [NC]
however when I test a page that doesn't exist and it 404s, it doesn't redirect at all to 404.php. For instance if I try a random page like asdf.html, it doesn't show the custom 404 page or even say can't find 404.php, it says it can't find asdf.html which means the redirect never takes place. Can anyone shed some light on why it doesn't redirect?
Thank - you!
p.s. my website resides in /var/www/html for reference

htaccess rules not working on my index.php file

I added this rule to my (htaccess) file on my root web server so that should anyone try to access lets say /web server/test then index would take the 'test' input as string but it is not working it keeps on saying error 404 not found.
My code is below:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine on
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
Are there any faults in this?
Below is my apache2 conf file.... As I get error 500 after changing my settings to override all.
Now I am getting error 500 ... so that I can provide more information... below is my htaccess file code
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
php_flag magic_quotes_gpc off
RewriteEngine On
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
And my apache2.conf file.....
<Directory />
Options FollowSymLinks
AllowOverride All
#Require all denied
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share>
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
two key points you need attention .
ensure your root directory can be overwrite by apache , please check the apache configuration , correct setting by below:
<Directory />
Options FollowSymLinks Multiviews
#AllowOverride none
AllowOverride All
Order allow,deny
Allow from all
# Require all denied
</Directory>
check your rewrite rules and ensure them can work. On your case i test following rules and work fun on my local.
RewriteEngine On
RewriteRule ^(\w+)$ /index.php?page=$1 [L]
Hope this can help you!

Xampp Virtual Host for sub directory

Question
I would like to map
www.mydomain.com/some/url
to
C:/xampp/htdocs/some/dir
What I've got
Xampp
Wordpress
htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /some/path/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /some/path/index.php [L]
</IfModule>
Hosts file
127.0.0.1 www.mydomain.com
httpd-vhosts.conf (included in httpd.conf)
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/someDir/"
ServerName mydomain.com/some/path
</VirtualHost>
additional info (httpd.conf)
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Current Outcome
500 Internal Server Error error log shows
Request exceeded the limit of 10 internal redirects due to probable configuration error.
Add the alias to your httpd.conf
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Alias /some/url C:/xampp/htdocs/some/dir

.htaccess not triggered

So I have the following .htaccess in my /var/www/site
RewriteEngine on
RewriteRule ^([^/]+)/?$ parser.php?id=$1 [QSA,L]
I have allowed override in my vhost:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/site>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
UPDATE:
Now I got it to work, however when I visit site.com, it also redirects me to this parser.php, in which I don't want as this is my homepage.
My homepage should be redirected to index.php and if I do mysite/NASKDj, it should be redirected to parser.php?pid=NASKDj. How do I fix this?
You have 'AllowOverride None' in the '/var/www/site' directory - this will overrive the one specified in the '/' directory. If your site is in /var/www/site you need to change This one to All too.
I just saw AllowOverride None in your <Directory /var/www/site>...</Directory>, So?

Categories