Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [htaccess]

The hypertext access web server configuration file used for overriding configuration on a per-directory basis.

60
votes
6answers
85k views

How do I rename a file to .htaccess in Windows 7?

I'm using XAMPP to test a PHP script. Now, in the root of the folder I want to place a .htaccess file according to the requirements of the script. But Windows won't let me rename it to .htaccess. Is ...
8
votes
4answers
13k views

How to show .htaccess files in specific folder in the Finder

I need to see my .htaccess files for the websites i develop locally on my Mac OS X. I put all my sites in the Sites folder. Since it starts with a dot, Mac OS X treats them as system - therefore ...
8
votes
1answer
10k views

pcfg_openfile: unable to check htaccess file, ensure it is readable

After moving a website folder on my local development machine to another drive, then moving it back, I got a 403 error. Most of this problem had probably to do with rights that got messed up. After ...
7
votes
1answer
35k views

.htaccess 301 redirect with regular expressions

If I have: redirect 301 /users/foo http://www.example.com/profiles/foo redirect 301 /users/bar http://www.example.com/profiles/bar Can I do something like? redirect 301 ^\/users/(.+)$ http://www....
6
votes
2answers
3k views

How can I highlight .htaccess code in Notepad++?

How can I highlight .htaccess code? I downloaded this XML file and I copy and pasted file content to userDefinedLanguage.xml inside my install directory. According to the documentation found here I ...
5
votes
4answers
7k views

How do I block a host by ASN? Example - AS16276

There are a handful of especially toxic hosts out there. There is no reason we need to allow any of their IP's access to our servers. Is there a way we can block them using their ASN or other global ...
4
votes
2answers
22k views

Using .htaccess with IIS

It is necessary for me to make it possible for .htaccess files to be usable with IIS. Is there a way for this to be done? I know that on its own, IIS is not capable of handling this, but could I ...
4
votes
1answer
8k views

configuring cgi-bin using .htaccess

I'm trying to configure a directory as cgi-bin using .htaccess, but when I try to access the executables, the files are downloaded. I'm using apache2.2. What is the problem? My .htaccess looks like: ...
4
votes
0answers
2k views

Redirect all HTTP traffic to HTTPS including subdomains

I'm trying to redirect all HTTP traffic to HTTPS including subdomains. I have the domain setup with FastComet on their Shared Hosting using cPanel. Some examples of how I like to redirect. http://www....
4
votes
0answers
521 views

why Safari always GET status 200, never 304 for my .swf file?

I serve a Flash app as a .swf file (with HTML wrapper file), and Safari always retrieves with GET status = 200, never 304. Thus, Safari never uses cache for this file and downloads it each time (it's ...
3
votes
1answer
2k views

How to show the whole file name while using .htaccess to list files in a directory?

My .htaccess file looks like this : Options +Indexes When I look at the directory from my browser, it looks like this: File names that are too long are truncated, how can I make it show the whole ...
3
votes
1answer
21k views

Proper Apache redirection from http to https

I set up a new virtual host for a new site on my server, but it's acting strangely despite having the exact same settings as my original site. I want all requests to be redirected to HTTPS, simply ...
3
votes
2answers
3k views

How to hide the PHP file extension using WampServer and .htacess file?

I just installed WampServer on Windows7 and uncommented mod_rewrite and set AllowOverride to All in the httpd.config file. I created an .htacess file and placed it in the root folder with the ...
2
votes
1answer
6k views

htaccess how to redirect if all other rules fail?

htaccess has always given my problems. Every time I think I understand it, htaccess goes against what I just thought I understood. Any help would be GREATLY appreciated. What I want to do with ...
2
votes
1answer
1k views

.htaccess Allow access not file by link only

I know that is possible to limit the access to a directory by the allow from ip.ip.ip.ip directive. But I've got a slightly(?) different problem: There is a directory, that contains pdf files only. I ...
2
votes
2answers
1k views

How to use .htaccess to block Russian IP addresses?

I added this code to my .htaccess file #deny all russian IP's Order allow,deny deny from .ru Allow from all My questions: Can it go anywhere in the file? I added it to the end. Do I put the code in ...
2
votes
1answer
5k views

how to redirect a url with port via htaccess

Im Trying to Redirect a Single url like http://tracker.niresh.co:12495/announce to http://tracker.niresh.co/announce.php How can i get it working through htaccess ?
2
votes
3answers
2k views

AllowOverride for userdir

I need to allow all userdir (host.com/~user) to override options in their .htaccess, such as php_value. Where do I configure Apache to AllowOverride ?
2
votes
1answer
2k views

Cross-origin directives in httpd.conf?

I am a part time Apache administrator (not by choice). We have an animated gif hit counter. I want to add a CSP to disable active content, but include a CORS policy to allow the gif for the hit ...
2
votes
2answers
6k views

Restart apache on Docker

I am trying to update my .htaccess file on a Docker container. After updating the file, I need to restart Apache. Whenever I try to restart Apache using the command service apache2 restart, I get the ...
2
votes
0answers
54 views

How to have .htaccess inherit defines from httpd.conf

I defined a path variable in my httpd.conf: Define OOSPATH D:/oos This define can be used anywhere in the httpd.conf or files which are included from there. The same path needs to be used in a ...
2
votes
1answer
7k views

Multiple htpasswd user entries [closed]

Using a Bitnami WordPress instance on AWS and the main issue I'm having is adding multiple users to my htpasswd file and have them authenticate to the site. Command : sudo apache2/bin/htpasswd apps/...
2
votes
0answers
152 views

Keeping Firefox from adding “.html” to url

I've been messing with .htaccess for a while, and have the following rule: RewriteRule ^(mypage|myotherpage)/?$ main.php?p=$1 [L,QSA] If I enter http://mydomain.com/mypage/, it displays main.php as ...
1
vote
3answers
393 views

Is it possible to rsync your web site to another backup server and use the same .htaccess files?

I am trying to use rsync to replicate all the files from one web server to another server that could act as a backup if the first one went down. The problem I am having is that the .htaccess file ...
1
vote
2answers
155 views

Is .htaccess necessary for Apache httpd?

I'm now setting up a weblog site and encountered this problem. My server is Apache httpd 2.2. In case my weblog pollutes the root directory(htdocs), I created a subdirectory blog. The current state ...
1
vote
2answers
1k views

How secure is .htaccess?

I've got a personal website I wish to lock down to everyone else except me. I've been using an .htaccess file for a bit and quite like it (they don't even see a webpage, just the login box), but will ...
1
vote
1answer
3k views

How can I compress a jpg images for google insights optimisation

I m getting this error when tring to see the speed of my website in google page speed: Optimize images Properly formatting and compressing images can save many bytes of data. Optimize the following ...
1
vote
2answers
293 views

Unhide all .htaccess files on mac

I am trying to unhide all the .htaccess files in my home folder. Below I've pasted what I'm using now, but it isn't working. find ~/ -iname ".htaccess" | xargs chflags nohidden "{}" Anyone knows why ...
1
vote
1answer
843 views

Multiple .htaccess auth sources

I'm attempting to use LDAP authentication alongside regular .htpasswd authentication, i.e., a user may use a valid LDAP user/pass OR one of the user/passes in .htaccess. The LDAP login is working ...
1
vote
1answer
5k views

How to configure XAMPP to list all files and directories, including index files?

I want to configure XAMPP to show all files and folders in a given directory, even index files. But when I browse to the directory, index.php is run automatically instead. What settings can I use in ...
1
vote
1answer
2k views

allow public access to subfolder of protected folder on apache

I have password-protected the root folder of my website while i do maintenance, but I want to display a custom 401 error page to let people know the site is under construction. Unfortunately, my web ...
1
vote
1answer
32 views

Allow http access only from two selected IPs and get alerts for other attempted logins

we want a system where our server can be accessed only by 2 selected systems. Also we need to log any other attempted access. One possible option we have is: order deny,allow deny from all allow ...
1
vote
2answers
5k views

Forcing HTTPS with .htaccess on site with Wordpress in subfolder

I can't get my .htaccess file to work to force HTTPS traffic Site structure that I see if I ftp to my hosting provider: / domains mydomainname.com public_html blog The files for ...
1
vote
1answer
153 views

Forward subdomain1.example.com to subomain2.example2.com using .htaccess

My Goal My main website is being hosted by a 3rd party server (Netfirms to be precise). I want most of my content hosted there. However, I am running an employee portal on a local server. The portal ...
1
vote
1answer
273 views

Apache is requesting .htaccess from user directory which is parent dir to DocumentRoot

I have my website/blog in /home/tarach/www/tarach.net All files and directories starting from /home/tarach/www are to user: tarach, group: www-data ( apache httpd group ) I've setup virtualhost ...
1
vote
1answer
832 views

mod_rewrite path info postfix and per-dir prrefix

There's an issue with .htaccess configuration. I just need the url /category to match the category.php script, but when I try to open this url, there's a 404 error instead. Here's my .htaccess: ...
1
vote
1answer
663 views

webserver serve file request with delay (htaccess)

I'm trying to figure out if it is possible to configure a webserver so that requests for files will be served with a delay. So for example if i were to serve this file http://www.example.url/picture....
1
vote
2answers
2k views

.htaccess not working with SVN

I've got SVN setup on my home server, I'm trying to get htaccess working so I can password protect the /var/www/html/svn/repos folder where all my code is kept. The subversion.conf file looks like ...
1
vote
2answers
32 views

Forwarding of root URL only?

I have a domain and I would like and visits to the root of the domain only to be forwarded. For example: www.domain.com -> www.domain.com/holding However www.domain.com/home www.domain.com/index....
1
vote
1answer
259 views

How can I prevent dead podcast links on our server being crawled by iTunes

Our work server was previously used to host a popular podcast link. The podcast is removed from iTunes but users are still trying to access the podcast link on our server. The user-agent strings in ...
1
vote
1answer
724 views

Redirect invalid paths using .htaccess (e.g. “home.php/xyz”)

I am running Apache 2.4.2 on my local server. My website's .htaccess file is as follows: DirectoryIndex home.php Options -Indexes ErrorDocument 404 /404.php This works great at displaying an HTTP ...
1
vote
2answers
4k views

Aptana show .htaccess files

Using the new Aptana Studio 2.0 and loving it. Trying to open and edit .htaccess files in Aptana Studio, but it's not showing up in the PHP Explorer pane, which normally shows all files, but not ....
1
vote
1answer
34 views

SSL forwarding for just one subdomain in .htaccess

I have Apache(ubuntu) server and I need to force https just for sub1.domain.com. Currently all traffic are being forwarded RewriteEngine On RewriteCond %{HTTPS} ...
1
vote
0answers
110 views

redirect subdirectory requests to alternate server:port

I'm using the following .htaccess to redirect requests to domain root ( http://example.com ) in apache to an alternate webserver on the same host listening on an alternate port ( http://example.com:...
1
vote
1answer
27 views

How to point URL to directory? [closed]

I need to point web url's like http://example.com/subdir1 http://example.com/subdir2 to same directory /var/www/vhosts/example.com/httpdocs/default/ on Linux hosting (Ubuntu 16.04, Apache2) - how ...
1
vote
0answers
674 views

Redirect multiple domains and subdomain with .htaccess

I am struggling with setting proper https redirect via a .htaccess file for my domains. I have the following domains, subdomains and directories: public_html/ -> www.red.com public_html/drk -&...
1
vote
1answer
154 views

How to block the htaccess login dialog box in pop-up ads?

Nowadays some websites won't let you use their platform without disabling your adblocker. I was recently exposed to a new type of pop-up ad : In order to avoid being closed quickly by the user, a ...
1
vote
0answers
472 views

How to define parameters/constants in Apache .htaccess files

I don’t have access to the Apache server configuration files and can only influence the configuration through .htaccess files. Unfortunately, this rather limits some things one might want to do. For ...
1
vote
0answers
133 views

Cannot load mod_rewrite Apache module

I am trying to use mod_rewrite module of Apache24 server, but I am not being able to load it. I know there have been many questions asked regarding this topic and I have gone through all of them but ...
1
vote
0answers
347 views

How to fix AddType or AddHandler problems

I recently moved from an old Godaddy hosting account to a new Godaddy Cpanel hosting account. The menus on the website are generated by using php include statements which worked on the old hosting ...