mod-rewrite

.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/...

Block user access to internals of a site using HTTP_REFERER

I have control over the HttpServer but not over the ApplicationServer or the Java Applications sitting there but I need to block direct access to certain pages on those applications. Precisely, I don't want users automating access to forms issuing direct GET/POST HTTP requests to the appropriate servlet. So, I decided to block users ba...

Using mod_rewrite to Mimic SSL Virtual Hosts?

What is the best way to transparently rewrite a URL over an SSL connection with Apache 2.2? Apache 2 does not natively support multiple name-based virtual hosts for an SSL connection and I have heard that mod_rewrite can help with this. I would like to do something like this: I have set up the server so that the sites can be accessed b...

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...

mod_rewrite to alias one file suffix type to another

Hi guys, I hope I can explain this clearly enough, but if not let me know and I'll try to clarify. I'm currently developing a site using ColdFusion and have a mod_rewrite rule in place to make it look like the site is using PHP. Any requests for index.php get processed by index.cfm (the rule maps *.php to *.cfm). This works great - so...

mod_rewrite rule to redirect all requests except for one specific path

I'm trying to redirect all requests to my domain to another domain using mod_rewrite in an Apache 2.2 VirtualHost declaration. There is one exception to this -- I'd like all requests to the /audio path not to be redirected. I've written a RewriteCond and RewriteRule to do this but it's not quite right and I can't figure out why. The ...

Any negative impacts when using Mod-Rewrite?

I know there are a lot of positive things mod-rewrite accomplishes. But are there any negative? Obviously if you have poorly written rules your going to have problems. But what if you have a high volume site and your constantly using mod-rewrite, is it going to have a significant impact on performance? I did a quick search for some benc...

Apache - how do I build individual and/or all modules as shared modules

On Mac OS X 10.5 I downloaded the latest version of Apache 2.2.9. After the usual configure, make, make install dance I had a build of apache without mod_rewrite. This wasn't statically linked and the module was not built in the /modules folder either. I had to do the following to build Apache and mod_rewrite: ./configure --prefix=/usr...

Apache rewrite based on subdomain

Im trying to redirect requests for a wildcard domain to a sub-directory. ie. something.blah.domain.com --> blah.domain.com/something I dont know how to get the subdomain name to use in the rewrite rule. Final Solution: RewriteCond %{HTTP_HOST} !^blah\.domain\.com RewriteCond %{HTTP_HOST} ^([^.]+) RewriteRule ^(.*) /%1/$1 [L] Or as p...

mod_rewrite equivalent for IIS 7.0

Is there a mod_rewrite equivalent for IIS 7.0 that's a) more or less complete b) suitable for a production environment, i.e. battle-tested/dependable/secure Do you have an experience-based recommendation? ...

Using Apache mod_rewrite to remove sub-directories from URL

I'm managing an instance of Wordpress where the URLs are in the following format: http://www.example.com/example-category/blog-post-permalink/ The blog author did an inconsistent job of adding categories to posts, so while some of them had legitimate categories in their URLS, at least half are "uncategorized". I can easily change Wor...

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...

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? ...

How to rewrite an URL on a JBoss server?

I would like to redirect/rewrite this two kinds of URLs: mydomain.com -> newdomain.com mydomain.com/specificPage -> newdomain.com/newSpecificPage mydomain.com/anyOtherPage -> mydomain.com/anyOtherPage (no redirect here) So I just want to redirect the root domain to a new domain, and some pages from my domain to some pages on a new do...

What are the bare basics you put down when you start a new PHP project?

I personally use the following method for all my sites. It has grown a little bit from using prefixed $_GET variables to using mod__rewrite but i have had these basics for a couple of years now. .htaccess: RewriteEngine On RewriteRule ^includes/ - [L] [OR] #do not apply for direct requests to /includes or RewriteRule ^images/ - [L] ...

Mod-rewrites on apache: change all URLs

Right now I'm doing something like this: RewriteRule ^/?logout(/)?$ logout.php RewriteRule ^/?config(/)?$ config.php I would much rather have one rules that would do the same thing for each url, so I don't have to keep adding them every time I add a new file. Also, I like to match things like '/config/new' to 'config_new.php' if that...

How do I use mod_rewrite to change the path and filename of a URL

I want to take the url: http://www.mydomain.com/signup-12345 And actually give them: http://www.mydomain.com/signup/?aff=12345 I have NO history with mod_rewrite, HELP! ...

Getting IIS6 to play nice with WordPress Pretty Permalinks

I've got a WordPress powered blog that I'm trying to get setup on our IIS6 server and everything works besides the permalink structure which I'm having a big headache with. After googling around/wordpress codex I learned that it's because IIS6 doesn't have the equivalent of Apache's mod_rewrite which is required for this feature to work...

apache mod_rewrite one rule for any number of possibilities

I'm building a fairly large website and my .htaccess is starting to feel a bit bloated, is there a way of replacing my current system of - one rule for each of the possibile number of vars that could be passed, to one catch all expression that can account for varying numbers of inputs ? for example i currently have RewriteRule ^([a-z]+...