Skip to main content
8 votes

A very simple router for a PHP application

There are many takes at that. And the most suggested one is to use a ready-made framework. But assuming this code as is: First of all, I don't see the real need for this router. Why not to request ...
Your Common Sense's user avatar
5 votes

A very simple router for a PHP application

I'm just going to comment specifically on the first two lines of the htaccess. ErrorDocument 404 /inc/index.php ErrorDocument 500 /inc/index.php That is asking for ...
Chris Haas's user avatar
5 votes

Serve rescaled jpg images on demand with myphoto!500.jpg syntax (here 500px-width rescaled)

If this were my code I'd be totally distrustful of the URI presented by my user. In other words I would assume that the results of the explode operations $f, ...
O. Jones's user avatar
  • 319
3 votes
Accepted

Serve rescaled jpg images on demand with myphoto!500.jpg syntax (here 500px-width rescaled)

Analysis The code looks acceptable; it is not difficult to read. The description does not state which image formats should be supported however the code appears to output resized images as JPEG images....
Sᴀᴍ Onᴇᴌᴀ's user avatar
3 votes

A very simple router for a PHP application

Quite aside from the above comments it's worth reading up on the PSR1 PSR2 and PSR12 linting rules. It has simple rules like a space after the if keywords if ( and ...
Alex Dawn's user avatar
3 votes
Accepted

Uploading and showing images securely

First, to your questions Do you spot anything wrong regarding permissions? Overkill. Permissions has very little to do with web-servers, as there is only one user - one under which a web-server (...
Your Common Sense's user avatar
3 votes
Accepted

HSTS Recommendations in .htaccess

There are two aspects to HTTP Strict Transport Security (HSTS): Implementing HSTS on your site. Submitting your already HSTS enabled site to the HSTS preload list. This is where the "list of ...
MrWhite's user avatar
  • 316
3 votes
Accepted

.htaccess Recommendations

https://gtmetrix.com/ notes that redirects are the largest culprit in slowing down my page loads gtmetrix.com's "suggestion" in this regard is arguably &...
MrWhite's user avatar
  • 316
3 votes

Protect against XSS with .htaccess file

The common definition of XSS is that code faults which allow someone to manipulate your website appearance, access prohibited sections of data, view inaccessible files or possibly steal credentials ...
HaniGamal's user avatar
  • 131
3 votes
Accepted

Adding, removing, and changing user names and passwords in .htpasswd with PHP

Here is my version based on two personal preferences: I hate scroll bars and I hate repititions. Hence I prefer everything typed once and also I like my code being fully visible in the default code ...
Your Common Sense's user avatar
2 votes

Adding, removing, and changing user names and passwords in .htpasswd with PHP

For the sake of your code and mine, I hope that the usernames cannot contain any colons since that is the delimiting character between usernames and passwords! I have a bias toward regex because I ...
mickmackusa's user avatar
  • 8,694
2 votes

Suggestions on how to improve this .htaccess file for page load speed

You can improve this code by removing unnecessary repetition. If you put a trailing slash after each declaration, then you do not need to repeat the same code over and over again. I would also suggest ...
Ryan Stone's user avatar
2 votes
Accepted

Load other files (from outside public_html) under index.php

Preface I wouldn't use the query string of the URL at all. The problem with using GET, is that GET is meant for other things such as bookmarkable search link etc. As you add more ...
ArtisticPhoenix's user avatar
2 votes

Load other files (from outside public_html) under index.php

You can simplify your regex pattern and you might like to combine your validation with the preparation step. The following pattern is just like yours except it allows a single trailing slash and ...
mickmackusa's user avatar
  • 8,694
2 votes
Accepted

Customized Apache host files

You don't actually need ServerName and ServerAlias directives for your port 80. This is due to the fact that your are using port-based virtual host. The "*" in the tag indicates that all incoming ...
Algo7's user avatar
  • 178
2 votes
Accepted

Apache2 mod_rewrite directive

It's an Apache config file. It isn't going to look pretty. :) That being said, I don't understand why you have RewriteCond specified for any of these rules. What is that condition preventing? The ...
Mike Brant's user avatar
  • 9,638
2 votes

.htaccess using public folder and SEO friendly URL

Redundant RewriteEngine declarations Unused match group in (public) Escaping (using \) is ...
hjpotter92's user avatar
  • 8,791
2 votes
Accepted

Directory listing in a web server

The variable $i is not used in the whole program. You should remove it. You output the <a> elements before the ...
Roland Illig's user avatar
  • 21.4k
2 votes

Protect against XSS with .htaccess file

Neither you .htaccess file or your .php file would be Vulnerable to Xss Attacks as they are both server side scripts which would never be Shown to a user & therefore would not be easily ...
Ryan Stone's user avatar
2 votes

Best way to deny .php in URLs while keeping access to those files through other URLs?

As I mentioned in a comment on your StackOverflow question: Your solution is very specific, it only works for those two cases. You could create a more general rule. Something like: "Every url ...
KIKO Software's user avatar
1 vote
Accepted

Understanding htaccess redirect to HTTPS and WWW

The code above works as expected. Why isn't the code in the next format, as it does the same thing? Is any difference ? ...
MrWhite's user avatar
  • 316
1 vote
Accepted

Direct to another folder with .htaccess file

The line you are using is telling the engine, redirect everything to the following URI. The reason for this is that you are using the pattern matching wildcard (.*). The parenthesis is used for ...
Innominatum's user avatar
1 vote
Accepted

Rewriting domain only if not on local dev enviroment and forcing www with Mod Rewrite

Yes! That is indeed correct. From the docs for RewriteCond: 'ornext|OR' (or next condition) Use this to combine rule ...
hjpotter92's user avatar
  • 8,791
1 vote

Redirecting HTTP requests to HTTPS

Since your actual machines are being handled by the Cloudflare based forwarding, you can let them handle the enforced SSL and www-prefixing rules instead. However, ...
hjpotter92's user avatar
  • 8,791
1 vote
Accepted

Redirect http to https, non-www to www and "/index.php" to "/"

Keep your code consistent. If you are using RewriteRule, use the same capitalisation format in all declarations. Same for setting the flags (...
hjpotter92's user avatar
  • 8,791

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