3

You could try following approach: location ~ ^/(?<cmd>[^/]+)/(?<scd>[^/]+) { try_files /index.php?cmd=$cmd&scd=$scd =404; } location ~ ^/(?<cmd>[^/]+)/ { try_files /index.php?cmd=$cmd =404; } location / { try_files $uri/ $uri.html $uri.php$is_args$args; } We use nginx location matching algorithm here to first check ...


2

You can create a symlink ln -s /var/www/html/files /var/www/html/public/files You will need Options +FollowSymLinks for this to work. Please note that this option adds a security risk as it allows accessing files outside of DocumentRoot. Alternatively you can add Alias /files /var/www/html/files to your VirtualHost configuration for this site. It is a more ...


2

The reason is the following block in nginx configuration: location ~.*\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|html|htm|txt|js|css|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|woff|ttf|svg|eot|sh|webp)$ { root /home/s4h/dl.domain123.org; expires max; try_files $uri $uri/ @backend; } This ...


1

If you are setting the X-Requested-With HTTP request header as part of the "AJAX request" (as would be implied if you are seeing $_SERVER['HTTP_X_REQUESTED_WITH'] in PHP) then you can check this header directly with mod_rewrite. For example, to serve a 403 Forbidden for any requests to the /scripts/ directory that do not have an X-Forwarded-With ...


1

In addition to @AlexD's answer... think this must be possible using mod_rewrite in the .htaccess file This IS possible using mod_rewrite, but not in .htaccess. You would need to do this directly in the main server config (or VirtualHost container). In a directory (or .htaccess) context you are restricted to rewriting to a URL-path only. However, in a ...


1

Using mod_rewrite you can do something like this: RewriteRule ^/?(subdir1)/olddirectory(?:$|/)(.*) https://www.example.com/$1/newdirectory/$2 [R=301,L] The above will redirect as follows: /subdir1/olddirectory to /subdir1/newdirectory/ /subdir1/olddirectory/ to /subdir1/newdirectory/ /subdir1/olddirectory/<something> to /subdir1/newdirectory/<...


Only top voted, non community-wiki answers of a minimum length are eligible