Questions tagged [.htaccess]
Directory-level configuration file used by Apache web servers.
45
questions
0
votes
1answer
43 views
Understanding htaccess redirect to HTTPS and WWW [closed]
I have some questions about a code I found on stackoverflow. The code does what I want to do. Redirects to HTTPS and WWW when doesn't exist in URL. But, I want now to understand what I'm doing.
So, ...
3
votes
2answers
68 views
Adding, removing, and changing user names and passwords in .htpasswd with PHP
Some code I wrote to add, remove, and change user names and passwords in .htpasswd with PHP:
...
5
votes
1answer
145 views
HSTS Recommendations in .htaccess
Please see my previous post in the below hyperlink
I've updated my .htaccess file to account for an HSTS, along with many of the recommended changes. See the ...
4
votes
1answer
149 views
.htaccess Recommendations
I have a personal website that's used primarily for fun. I upload images, videos and text that I want to share. An HTML submission form accepts questions and string submissions from users, which uses ...
2
votes
0answers
27 views
.htaccess template
I have an .htaccess template I have been working on that I want to submit for code review. I want to accomplish these things:
Custom error handling
Remove index.php if in url
Force HTTPS
Remove www.
...
2
votes
0answers
67 views
Apache reverse proxy security configuration
Could someone share some light and check if this is okay for apache httpd security/good standards? I'm using apache httpd to call my Node.js app that is running with Express and also configuring SSL.
...
3
votes
0answers
56 views
.htaccess file to enable compression, send security headers, and set cache expiration
This is the current .htaccess configuration for one of the website projects that I am working on, just as a learning exercise. This is working code and everything ...
1
vote
0answers
314 views
Implement versioning of a RESTful API with PHP/Slim and Apache
I want to create a RESTful API with Apache/PHP and the Slim Framework (3.x). The API should support URI-based versioning like ...
4
votes
2answers
273 views
Load other files (from outside public_html) under index.php
I wanted to load every page under index.php with a simple index.php?do=login
For example when the link index.php?do=login or <...
3
votes
1answer
305 views
Uploading and showing images securely
I've read various posts about how letting users to upload files can create vulnerabilities to your website such as a user injecting PHP code in an image.
So I've created a small test project where ...
1
vote
0answers
75 views
PHP OOP front controller pattern
I've started a course about the MVC pattern applied to the web. I want to improve my PHP programming skills so I've decided to write a simple boilerplate for my webapps that use the front controller ...
0
votes
1answer
44 views
Direct to another folder with .htaccess file [closed]
Lets say my folder structure looks like this
...
1
vote
1answer
33 views
Rewriting domain only if not on local dev enviroment and forcing www with Mod Rewrite
I'm trying to write some mod rewrite code to redirect pages on a site to always use www and this has been working fine:
...
4
votes
1answer
52 views
Redirecting HTTP requests to HTTPS
I have read a lot and spent a lot of hours trying to reach the right way to set a good htaccess in order to redirect an HTTP site to HTTPS.
There are a lot of tutorials on the Internet, even on Stack ...
5
votes
1answer
123 views
Redirect http to https, non-www to www and “/index.php” to “/”
Is this htaccess code the best/proper way to:
Send all http traffic to https
Send any visits to index.php to the URL that doesn't show "index.php"
Send all non-www traffic to www
This code works ...
2
votes
1answer
52 views
Customized Apache host files
I'm using customized Apache host files for my Digitalocean websites. Please review the code, whether it's following the good standards or not, and please mention if I'm missing something important. ...
1
vote
1answer
233 views
htaccess with compression, caching, and rewrite rules for SEO
I have the following htaccess and I want it to be the perfect htaccess for my website so that it uses less bandwidth and meets the requirements of a good SEO.
I am on an apache server and my files ...
2
votes
1answer
23 views
Apache2 mod_rewrite directive
The website I'm working on is essentially project-management software. Each project has a code (alphanumeric lowercase, with hyphens). The URL must include the codes and treat them as directories.
<...
4
votes
1answer
593 views
.htaccess using public folder and SEO friendly URL
.htaccess is not my strong suit. Is there any there can optimize this code?
...
-3
votes
1answer
386 views
Directory listing in a web server
I have Ubuntu 16.04 with standard apache web server installed. Nothing special about it. No open ports but 80.
Instead of the default index page I put this one:
...
0
votes
2answers
2k views
Protect against XSS with .htaccess file
My .htaccess redirects everything to my index.php, but I wonder if it's vulnerable to XSS attacks. Am I safe?
.htaccess file
...
5
votes
2answers
213 views
Securing PHP using a gateway that consults a whitelist
My site was recently infected and running malicious scripts. Once I discovered this, I cleared everything, the hosting company re-initialized the VPS and I setup my site anew. This is how I run my PHP ...
1
vote
1answer
154 views
Basic settings, custom error page, dynamic versioning, rewrite rules
Any suggestion is more than welcome! I had to do a few tricks in rewrite rules (checks on ENV:REDIRECT_STATUS) to avoid infinite loops, but it works fine.
error....
7
votes
1answer
6k views
Creating an object-oriented router class in PHP
On my way to learn OOP, I am developing a little CMS using the MVC pattern. I would like to have some feedback about my router class, mostly about if I am correctly using OOP.
Right now, I have a ....
2
votes
1answer
167 views
Complex .htaccess
After 8 years with the same Apache webserver, the .htaccess file seems to be a bit heterogeneous. I have taken some care about readability, but there are still some problems (such as pages with www. ...
4
votes
2answers
73 views
2
votes
2answers
165 views
Prettifying URLs for a PHP-based club website
I have a website for my car enthusiast club ("example.org") whose content can be divided into three main sections: Startseite (the "front page" of the site), Mitglieder (membership directory), and ...
5
votes
2answers
47 views
5
votes
1answer
279 views
Redirect for subdomains and secondary domains
I've just edited my .htaccess file. All works as it should, but I'm not too familiar with regular expressions and want to make sure that there aren't any unintended ...
2
votes
2answers
97 views
301 redirect using .htaccess
I wonder if the following 301 redirect is the best way for my situation. I used this post on SO to give me the following 301 redirect:
...
7
votes
1answer
126 views
An .htaccess for our entire site
We have this long .htaccess mainly rewriting our URLs. Everything works fine (except blog titles containing a ' , but we're ...
0
votes
2answers
969 views
All-purposes AJAX handler made with PHP and .htaccess that speaks JSON
In a project I've started, I decided to implement some new code to handle AJAX requests.
The requirements are that it can ONLY access the /ajax/ folder, load ...
1
vote
2answers
511 views
Redirecting all pages under a certain directory to a single file
I want to redirect all pages under a certain directory to a single file, like so:
/dir/a → /dir/new
...
3
votes
1answer
38 views
Faults using mod_rewrite
I never really bothered using mod_rewrite to achieve SEO friendly names but I've always admired from a distance because I've never been good at regex.
The below .htaccess file does work, but I'm ...
4
votes
0answers
157 views
.htaccess index.php removal, static content serving
I am writing a CMS type application and I am trying to restrict how the server gets accessed.
Any content (in js/, css/ or images/ directories) should be served as is, as long as there is an index....
2
votes
1answer
56 views
Forcing SSL and WWW using .htaccess
I would like to know if this code in .htaccess for forcing SSL and WWW in URL is correct, because with another code I usually get redirect loop, e.g. ...
3
votes
1answer
341 views
htaccess for URL remapping, caching, and compression
I have been collecting snippets from all over the place and then put them all together creating the following .htaccess file.
I really don't understand if what I have done below is good/should work ...
15
votes
1answer
391 views
Portable website template
I have spent the last 6 months as I am studying web development in college to build a website template that is responsive and accessible from as many devices and browsers as possible.
I would really ...
5
votes
1answer
201 views
Review URL-prettifying .htaccess file
Can anyone please review the following .htaccess file and let me if it is correctly put together?
What I think it does:
So it direct to a custom 404 page
Remove ...
3
votes
0answers
2k views
Automatically redirect /index.php files to their URL directory with .htaccess
The requirements:
Work inside .htaccess (preferably via mod_rewrite)
Redirect requests from /any/directory/index.php to ...
2
votes
2answers
807 views
Is it ok to use PHP's strpos and substr altogether in one statement?
I am using PHP to build a REST API. I want to receive requests from the URL in the following format:
http://mydomain.com/api/format/method?app_id=value&call=encrypted_request
So, I have modified ...
2
votes
1answer
118 views
Can my router code be improved?
I have created a nice url structure for my site.
In my .htaccess I have:
FallBackResource /index.php
And in my router class I have:
...
7
votes
1answer
273 views
Canonicalize URLs for static website
I want to "canonicalize" URLs for my static (files and folders) website.
The 'Aims' describes what I want to accomplish. The 'Code' gives my current .htaccess.
...
6
votes
2answers
216 views
Suggestions on how to improve this .htaccess file for page load speed
Here is my standard .htaccess file, any suggestions on how I can improve it with regards to page load speed? Would gZip instead of DEFLATE make any sort of difference?
...
8
votes
2answers
6k views
MVC router class
Below is what I have come up with for a router/dispatcher system for my personal framework I am working on. Can you please review and tell me any improvements that could be made?
The first part is ...