Questions tagged [.htaccess]

Directory-level configuration file used by Apache web servers.

Filter by
Sorted by
Tagged with
2
votes
0answers
58 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. ...
2
votes
0answers
29 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 in it seems to be ok, My hosting ...
1
vote
0answers
96 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
175 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
289 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
67 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
39 views

Direct to another folder with .htaccess file [closed]

Lets say my folder structure looks like this ...
1
vote
1answer
31 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
44 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
111 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
49 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
198 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
22 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
568 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
372 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
161 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
149 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....
6
votes
1answer
5k 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
139 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
72 views

301 Redirecting

Is there anything I could do to improve the following .htaccess code? ...
2
votes
2answers
132 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 ...
4
votes
2answers
45 views

Mapping several URLs to one login page

My htaccess has this block in it: ...
5
votes
1answer
270 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
89 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
117 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
884 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
435 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
154 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
53 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
326 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
384 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 ...
4
votes
1answer
176 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 ...
2
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
806 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
268 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. ...
5
votes
1answer
198 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 ...