PHP 7 Script not display errors, or writing them to the log

I’ve been bashing my head trying to port some super old PHP script to PHP 7.0, which is proving impossible because I can’t figure out what the errors are! If I implement some sort of syntax or parse error, the script happily shows those to me, but I cant get any errors that tell me my function is undefined when I try to call lkasjdfalkjshdfasdF(); (which obviously isn’t set).

Things I’ve tried:

This is my .htaccess file in the same directory as my script

php_flag display_startup_errors on
php_flag display_errors         on
php_flag html_errors            on
php_flag log_errors             on
php_value error_log             "/var/log/apache2/error.log"

I also have this at the top of my script

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

If I add echho 'test'; on one of my lines, it shows the following on the page, and in the error log

Parse error: syntax error, unexpected ''test'' (T_CONSTANT_ENCAPSED_STRING) in /domains/ on line 200

If I add echo asdfasdf(); on one of my lines, I get no output, and there’s nothing in the error log.

I even wrote this silly function

$DebugPointCointer = 0;

function DebugPoint() {
    global $DebugPointCointer;

    echo "Debug point $DebugPointCointer on line " . debug_backtrace(1)[0]['line'] . "n";


So I could make sure that the script was failing where I suspected, but in all honesty, that information didn’t really help me.

What’s left to try?

Source: stackoverflow-php

.htaccess mod_rewrite [P] for https

I have the following code in my .htaccess:

<ifModule mod_rewrite.c>
#RewriteCond %{HTTP_HOST} ^
RewriteCond %{REQUEST_URI} !^/social/retrievePage.php 
RewriteRule ^(.*)${REQUEST_URI} [P]

Basically it will remap any page to and pass REQUEST_URI as page GET parameter.

It works well, however when I set SSL certificate for my domain, this will not work as expected, instead of remapping it will make a 301 Redirect

I tried fixing the issue by replacing http to https from RewriteRule, got 500 Internal Server Error.

What could be the issue?

Source: stackoverflow-php

PHP page start downloading instead ot showing content

I am trying to make working laravel 5.4 on shared hosting. I am using below code of .htaccess file, but it start downloading files instead of showing content. below is my .htaccess code.

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /public/([^s?]*) [NC]
RewriteRule ^ %1 [L,NE,R=302]

RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
# Use PHP70 as default
AddHandler application/x-httpd-php70 .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/php70/lib

I don’t know, where I am getting wrong.

Source: stackoverflow-php

Rewrite URL remove part of URl

I need to remove part of a url.

I want to redirect this request without api in path to a file located in the same directory named api.php

I have following directory structure

root/api/{here we are}

So I need that my api.php file only receives user/1 in this case

I have tried the following configuration, but it doesn’t work – Not Found

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/(.*)$ api.php/$1 [L]

Please help to get this working

Source: stackoverflow-php

Rewrite URL to hide id

I have the following url on my website:

I want to rewrite it in htaccess so that it appears as:

What regex do i need to use in this scenario for the proper rewrite?

Source: stackoverflow-php

.htaccess thumb php image link

I want to make better links to thumb image with php

my current image link to thumb


but I want in this form


I tried with this htaccess code

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+|)/?$ thumb.php?size=$1&src=../data/$2
# Handle requests for "thumb.php"

Where the error and how to fix it?

Source: stackoverflow-php

Transfering mod_rewrite rules from htaccess to nginx

I am trying to convert some already working rewrite rules from .htaccess to nginx.
My application has 2 modes, backend (all calls starting with /admin/*) and frontend, the rest of the calls. Backend requests get routed to admin.php while frontend ones get routed to index.php

This works great in apache but in nginx I can only get the frontend routing to work. The /admin/ requests do call the admin.php file but the php file is downloaded instead of being executed. I’ve already used to convert my htaccess routes to nginx but I still can’t get it to work for /admin.

Can an nginx pro help me out with the proper config to do this?

This is my working .htaccess config:

<IfModule mod_rewrite.c>
#RewriteBase /

# Google sitemap.xml configuration
RewriteRule sitemap.xml$ /index.php?_extension=Frontend&_controller=Sitemap&action=googleSitemap [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+).(d+).(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

# admin routes
RewriteRule ^/admin/(.*)$ admin.php?%{QUERY_STRING} [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

# frontend routes
RewriteRule .* index.php [L]


and this is the nginx configuration that I tried so far…

server {
    listen       80;
    server_name  mydomain.local;
    root   /var/www/project;
    index  index.php index.html index.htm;
    access_log  /var/log/nginx/default-access.log  main;
    error_log   /var/log/nginx/default-error.log;

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {
        root   /var/www/default;

    location / {
        rewrite sitemap.xml$ /index.php?_extension=Frontend&_controller=Sitemap&action=googleSitemap redirect;
        try_files $uri $uri/ @rewrite;
    location @rewrite {
        rewrite ^(.*)$ /index.php;
    location /admin {
        rewrite ^/admin/(.*)$ /admin.php?$query_string break;

    location ~ .php {
        include                  fastcgi_params;
        fastcgi_keep_conn on;
        fastcgi_index            index.php;
        fastcgi_split_path_info  ^(.+.php)(/.+)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
        fastcgi_pass unix:/var/run/php-fpm.sock;

with nginx on, doing a curl -s -D – ‘http://mydomain.local/frontend/call‘ | head -n 20 does return the Content-type as text/html while a call to curl -s -D – ‘‘ | head -n 20 returns the application/octet-stream content type which triggers the download.

Source: stackoverflow-php

Not needed 3 parametres from $_GET htaccess

So I’ve got link like


And how do I make it if I would type


I wanna it to be interpreted by .htaccess to array

$_GET = [ 'sub' = 'main', 'fun' = '', 'id' = '' ]

but also If I would type


to get

$_GET = ['sub' = 'main', 'fun' = 'show', 'id' = '23']

Source: stackoverflow-php