mod-rewrite

Apache Rewrite: directory tree to subdomain directory

I have a web application that has one set of files used by 50+ clients and all the configuration for each site comes from a config.php file in their respective directories. This is accomplished with PHP parsing the URL. All this works fine, just having an issue with custom uploaded documents the client can do and are located in /var/w...

What mod_rewrite rule will 301 redirect /example.html to /example?

I would like to translate or 301-redirect urls such as: www.domain.com/example.html to www.domain.com/example Here are the current rewrite rules: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] RewriteCond %{SERVER_PORT} 80...

like twitter url with rewritecond????

I would like a simple help. I have a URL like this: /profile.php?id=<id>&name=<name>. My .htaccess file like this: RewriteRule ^profile/(.*)/(.*) profile.php?id=$1&name=$2 So I have a end URL like this: /profile/<id>/<name>. I can make /<id>. But how can I get a URL like /<name>? I can use the RewriteCond to make a conditional? I s...

.htaccess mod_rewrite just broke the site...

hello, in the following .htaccess file... RewriteEngine on RewriteCond %{HTTP_HOST} ^getpearson.com$ RewriteRule ^/?$ "http\:\/\/www\.getpearson\.com" [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^ - [L] RewriteRule ^rede...

Mod_rewrite, how to stop rule applying to one query string?

Hi, I have a list of rewrite rules, but one of the rules is applying to something I need it to not apply to. Here is the rewrite rule causing the problem, RewriteRule ^([^/]*)/$ /category.php?category=$1 [L] It's meant to rewrite .com/catname/ to /category.php?category=catname which it does fine, but I need it to not apply to anythin...

ReWrite RegEx, URL having at least one character.

I have the following RewriteRule: RewriteRule ^/people/([A-Za-z0-9\-\_]*)/?$ /people/people_details.cfm?person=$1 [I,L] ...it works great for forwarding my rule, but I want to make sure that the regex only picks it up if it has more than one character. So really, I need to have my regex... [A-Za-z0-9\-\_]+ ...have an additional r...

Subdirectory .htaccess affecting other directories

I'm having a strange .htaccess issue. My web structure is setup like so to have two sites: www/site1/ www/site2/ inside the site1 directory, I have a .htaccess file with rewrite rules in it. Inside the site2 directory, I have a different .htaccess file with different rewrite rules. My problem is that the rules in www/site1/.htacces...

htaccess vs password protected directories

I have to add a password protected zone to a site I am working on (using the .htpasswd file). The thing is the whole directory structure it's being pointed at doesn't exist and is created through mod_rewrite. Will it still work, or does the directory actually have to physically exist on the server? Clarification: While I may need to p...

htaccess redirection problem alias vs. directory name

When I use this rule: RewriteRule ^Chats/([^/]+)/?$ Chats/ChatPage.php?chaturl=$1 [NC] I get $_GET["chaturl"] as ChatPage.php where I should get $1. How can I solve it? If alias and directory name are not the same, there is no problem. If I use RewriteRule ^Chat/([^/]+)/?$ Chats/ChatPage.php?chaturl=$1 [NC] (NOTICE IT'S CHAT NOW NOT CH...

Rewriting URLs and "faking" folders

Hi, I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The folders don't exist, but "virtually" exist for the rewriting purpose. What rule do I used in this? ...

Redirecting with mod_rewrite and mod_geoip only if user asks for the root of the domain and are from a particular country

Hi, I need a rule and condition to handle this scenario: User from US visits www.domain.com, domain.com, www.domain.com/ or domain.com/ this should be redirected to www.domain.com/usvisitor/ However, if a user from the US visits www.domain.com/anydirectory it will let them straight through without a redirection occurring. eg. Rewrit...

htaccess mod_rewrite check file/directory existence, else rewrite?

I have a very heavy htaccess mod_rewrite file that runs my application. As we sometimes take over legacy websites, I sometimes need to support old urls to old files, where my application processes everything post htaccess. My ultimate goal is to have a 'Demilitarized Zone' for old file structures, and use mod rewrite to check for existe...

Configuring mod_rewrite and mod_jk for Apache 2.2 and JBoss 4.2.3

Hello! My problem is as follows: I have JBoss 4.2.3 application server with AJP 1.3 connector running on one host under Windows (192.168.1.2 for my test environment) and Apache 2.2.14 running on another FreeBSD box (192.168.1.10). Apache acts as a "front gate" for all requests and sends them to JBoss via mod_jk. Everything was working fi...

SSL and mod_rewrite error

Hi, I have https on my site. Pages with rewritten URL in my site are inaccessible while direct urls (folders). here's the htaccess ## 2009-12-17 16:52 JGC [START] ## Enable http compression for this site <IfModule mod_deflate.c> SetOutputFilter DEFLATE ## Directive "DeflateCompressionLevel" not allowed in .htaccess, only valid in...

Redirect in combination with a rewrite condition in htaccess

Hi all! I've got a cms-driven website, with no option to change the code. What I want to accomplish is creating friendly url's, using only apaches mod-rewrite engine. The problem is I'm creating an infinite loop, because I first redirect the original url (index.php?id=21) to a friendly one (/friendly/) and then rewrite the '/friendly' ...

How to use URL Rewrite on IIS for a single code base for multiple sites in PHP.

I have used the Apache Mod Rewrite for PHP but not in IIS. BACKGROUND: I have inherited over 400 sites on IIS with PHP all with a copy of the identical code base. The current code base has a unique connection string per client and that is why it was copied over and over again. Each being a subdomain pointing an individual site in IIS:...

Htaccess Rewrite Rule

Hi, I'm getting crazy with .htaccess and rewrite rule. I'd like to understand how it works, I hate it, anyway here's my problem. (really simple for most of you) My site has one main page index.php. This is the only page, all the others are handled by this one. I did a simple RewriteRule: RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page...

How to rewrite a URL with %23 in it?

I have a (wordpress) blog where after commenting the users are redirected back to the page with an anchor to their comment. Should look like this: http://example.org/foo-bar/#comment-570630 But somehow I get a lot of 404 ins my logfiles for such URLs: http://example.org/foo-bar/%23comment-570630 Is there a way to write a .htaccess re...

rewriting single url help

Hi, I'm trying to rewrite the following url: index.php?route=checkout/cart to /cart using: RewriteRule ^index.php?route=checkout/cart$ /basket [L] However it doesn't seem to work. Anyone know what I'm doing wrong? Thanks ...

mod_rewrite browser trying to get content from non-existant dir

I have my mod_rewrite set up so that it redirects all requests that aren't targeting existing files or directories to index.php?req=* where * is the request. Works all fine but when I send the browser to something like this: http://myurl/A/B/C The browser tries to find all images, stylesheets in the non-existing folder C. How can I m...