.htaccess

.htaccess directives to *not* redirect certain URLs

In an application that heavily relies on .htaccess RewriteRules for its PrettyURLs (CakePHP in my case), how do I correctly set up directives to exclude certain directories from this rewriting? I.e.: /appRoot/.htaccess app/ static/ By default every request to /appRoot/* is being rewritten to be picked up by app/webroot/...

Mod-Rewrite loading files behind the DocumentRoot

I'm using htaccess and mod_rewrite to point to files that reside behide the DocumentRoot. My folder structure looks like this: home/ webroot/ other_files/ I have a .htaccess file in webroot with the following: RewriteEngine on RewriteRule ^(.*)$ /home/other_files/$1 If I try and access http://mysite.com/file.h...

How do I add a MIME type to .htaccess?

I would like to add the following MIME type to a site run by Apache: <mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping> (That is the Tomcat format.) I'm on a shared host, so I can only create an .htaccess file. Would someone please specify the complete contents of such a...

How can I use `scp` to deploy a website's `.htaccess` file?

I am currently using the following command to upload my site content: scp -r web/* [email protected]:site.com/ This works great except that the .htaccess file is not sent. Presumably, this is because it's hidden. I have tried adding a second line to send the file explicitely: scp -r web/.htaccess [email protected]:site.com/.htaccess This ...

Redirecting non-www URL to www

I'm using Helicon's ISAPI Rewrite 3, which basically enables .htaccess in IIS. I need to redirect a non-www URL to the www version, i.e. example.com should redirect to www.example.com. I used the following rule from the examples but it affects subdomains: RewriteCond %{HTTPS} (on)? RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC] Rewrite...

Wildcard Subdomain Exceptions

I have a wildcard subdomain enabled and dynamically parse the URL by passing it as-is to my index.php (ex. somecity.domain.com). Now, I wish to create a few subdomains that are static where I can install different application and not co-mingle with my current one (ex. blog.domain.com). My .htaccess currently reads: RewriteEngine On...

How to convert Apache .htaccess files into Lighttpd rules?

It's big problem to convert mod_rewrite rules to lighttpd format ...

How do I use .htaccess to redirect to a URL containing HTTP_HOST?

Problem I need to redirect some short convenience URLs to longer actual URLs. The site in question uses a set of subdomains to identify a set of development or live versions. I would like the URL to which certain requests are redirected to include the HTTP_HOST such that I don't have to create a custom .htaccess file for each host. Ho...

Is it possible to use .htaccess to send six digit number URLs to a script but handle all other invalid URLs as 404s?

Is it possible to use .htaccess to process all six digit URLs by sending them to a script, but handle every other invalid URL as an error 404? For example: http://mywebsite.com/132483 would be sent to: http://mywebsite.com/scriptname.php?no=132483 but http://mywebsite.com/132483a or http://mywebsite.com/asdf would be handled as...

How to make a web app appear at the root of the site?

I have a bulletin board (punBB based) that I was running out of the root directory for a couple of years. I foolishly decided to do a little gardening and in the process moved the punbb code into it's own subdirectory. The code works great; as long as you point the browser at the new subdirectory. The issue is that the users expect to se...

.htaccess mod rewrite 301-redirect

I want: all links which not contained filename (not .html, .jpg, .png, .css) redirect with state 301 to directory, for example: http://mysite.com/article -> http://mysite.com/article/ But http://mysite.com/article/article-15.html not redirects. What regulat expression I must write to .htaccess for adding slash to virtual directories? ...

Dynamic IP-based blacklisting

Folks, we all know that IP blacklisting doesn't work - spammers can come in through a proxy, plus, legitimate users might get affected... That said, blacklisting seems to me to be an efficient mechanism to stop a persistent attacker, given that the actual list of IP's is determined dynamically, based on application's feedback and user be...

Apache Mod-Rewrite Primers?

I am wondering what primers/guides/tutorials/etc. are out there for learning to rewrite URLs using Apache/.htaccess? Where is a good place to start? My primary interest is learning how to point certain directories to others, and how to use portions of a URL as parameters to a script (i.e. "/some/subdirs/like/this" => "script.php?a=some&...

Do you have to restart apache to make re-write rules in the .htaccess take effect?

I have pushed my .htaccess files to the production severs, but they don't work. Would a restart be the next step, or should I check something else. ...

Edit php.ini with .htaccess

I'm slowly getting back into PHP, and now I run into a problem, I want to install some web software on our host and I need to have either the latest Zend (which they don't have) or IonCube on the server and IonCube requires enable_dl to be on in the php.ini. Now a colleague of mine thinks I can update this via an .htaccess file on the se...

Apache/php guru needed! htaccess files, php, includes directories, and windows XAMPP configuration nightmare!

XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite disappointing that enabling htaccess files is such a nightmare. My problem: I've got a PHP application that requires apache/php to search for an /includes/ directory contained within the application. To do this, htaccess files must be allowed in apache and ...

What happens first? .htaccess or php code?

If I use mod_rewrite to control all my 301 redirects, does this happen before my page is served? so if I also have a bunch of redirect rules in a php script that runs on my page, will the .htaccess kick in first? ...

How do I stop visitors directly accessing the directories in my website?

I have a (Wordpress powered) website, and Google is indexing some of the sub-directories. How can I stop Apache from showing users the directory listing? I know I can edit .htaccess to password-protect a directory, but I would prefer a 403 / custom redirect if possible. ...

Apache htaccess on Win2k is not being processed

I am trying to rewrite URLs using mod_rewrite. It is enabled in httpd.conf and url rewriting works if the lines are in the httpd.conf file. However, I would like the rules to be in the .htaccess file. It doesn't appear that .htaccess is being processed at all by Apache on Win2k. I have ReWriteLogging turned all the way up, but the log...

Getting file name of file directed by .htaccess?

Hello. I'm making a dynamic image for a forum that doesn't allow dynamic images. I tried using .htacess to redirect all *.png files to image.png... which works perfectly, but from here I can't seem to be able to get the filename of the .png that was requested to generate the content. is there a way to do this? For example... user ...