Skip to content

Tag: .htaccess

store constant variable on server via .htaccess

I would like to store the INDEX_URL constant the easiest way possible. There is a developer site and a normal site. If there is any change on the developer site, I would like to just copy the entire files but this constant is not the same on the 2 sites. I have made this test: It seems it does not

Custom Error 403 Page PHP

I created a .htaccess inside a directory in which I don’t want the files to be directly accessed. It works and fires the default 403 page (Access forbidden!) of the Apache server. How can I create a custom 403 page? Thanks! Answer In your .htaccess file you can specify what document you want as your def…

Altering .htaccess with PHP – removing a rewrite rule

I am using PHP to remove/add static pages once a page has been deleted, I want to be able to remove it from the .htaccess, however I’ve tried this, but it throws an error: Warning: preg_replace() [function.preg-replace]: Unknown modifier ” in … The code: This is an example of what it should …

htaccess access to file by ip range

How to allow access to file only to users with ip which are in a range of ip addresses? For example file admin.php. and range from 0.0.0.0 to 1.2.3.4. I need configure access to only ONE file not to directory. Answer Just add a FilesMatch or Files directive to limit it to a specific script. The following woul…

How to enable gzip?

I have found a couple of tutorials on how to enable gzip, but nothing seems to be working for me, so my question is how do i enable gzip. I am on a shared Dreamhost hosting server, It is running PHP …

.htaccess 301 redirect of single page

After a site redesign, I’ve got a couple of pages that need to be redirected. Everything is staying on the same domain, just a couple of things have been reorganised and/or renamed. They are of the form: /contact.php is now: /contact-us.php Using the .htaccess file, I’ve added this line, which is …