mod-rewrite

[Apache] Unwanted mod_rewrite behaviour

I just did a fresh install of lamp stack on ubuntu and enabled the mod_rewrite module for my default website. What I want is something similar to the drupal's queries, when the whole query string is kept in one variable. For this purposes the following mod_rewrite code may be used: RewriteRule ^(.*)$ home.php?q=$1 [L,QSA] The problem ...

Apache mod rewrite simple redirect

I want requests to my site to work as follows: http://example.com/ would pull up the index.php file (the current default behavior) ideally without displaying the index.php http://example.com/foo.php would pull up foo.php as would be expected http://example.com/blerg would redirect to http://example.com/bar.php?code=blerg I have the f...

How to match subdirectories in RewriteCond?

Having trouble with proper regex for RewriteCond RewriteCond %{REQUEST_URI} !^/foo/ Works as expected, that is, does not apply following rewrite to all URLs that start with /foo/. RewriteCond %{REQUEST_URI} !^/foo/bar/ On the other hand does not work as I expect. URLs that begin with /foo/bar/ are still being rewrited. How do I en...

Rewrite rule-- If incoming request is not consist of certain characters then rewrite to other URL

How to construct a rule that checks if the incoming request is of certain terms, if no, then reroute to other URL? For example, I have a website my.example.com. If the incoming URL is my.example.com/login then it should execute that request. If it's something else (not login), then the request must be reroute to your.example.com. For ex...

.htaccess and rewrite of URL

We have the following example "ugly" URL: https://some.uglyurl.com/directory/test.jsp?hotelid=1111&rateplanid=33333 we need to direct our customers to the above URL using our own domains URL as the address - so it would look something like: https://www.PrettyURL.com/reservations?hotelid=1111&rateplanid=33333 The idea being ...

Mod Rewrite - Simple Question

This is my current .htaccess Options +FollowSymLinks DirectoryIndex index.php RewriteEngine On RewriteBase /product/ RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteRule ^(.+)\.php$ ./$1/ [R=301,L] RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L] RewriteRule ^contact/?$ ./contact.php [QSA,L] Everything i...

Online mod_rewrite testing tool

mod_rewrite statements can be hard to write and debug, therefore I need a lightweight online tool that enables me to test my RewriteCond, RewriteRule statements on the fly. Any such tool? ...

How can I get non existant files mapped correctly in .htaccess?

Duplicate: How to rewrite non existant files to ‘default’ files? (.htaccess) How would I "rewrite" to a location if a file doesn't exist? I don't want to use a 404 redirect, but an actual rewrite. So for example, let's say it is a directory with images. If the image isn't found, then it rewrites to a default image? I.e., ima...

RewriteRule not obeyed

http://localhost/allsides/.htaccess RewriteRule (.*) index.php?$1 [L] http://localhost/allsides/test One or more chars after allsides/ are saved in $1 $_GET is $1. test is not $_GET! What is wrong? ...

.htaccess URL Rewrite to Subdirectory

What is the best method to rewrite anything below "/some/subdir" to "/some/subdir/projects" like from this: http://www.mydomain.com/some/subidr/test/ ... to this: http://www.mydomain.com/some/subdir/projects/test/ I found a similar question posted, but the solution didn't seem to work in my case. My current attempt so far (which do...

Zend/Apache mod_rewrite... what's wrong?

The following url works ok: http://localhost/index/index/ However, I am unable to _get$ variables when they come in like this: http://localhost/index/index/test/1234/test2/4321 -but- I can however, _get$ the variables these ways: http://localhost/index.php?test=1234&test2=4321 http://localhost/index?test=1234&test2=4321 h...

htaccess URL rewriting speed optimization

My server support tells me my htaccess URL rewrites are causing an overhead. I use URL rewriting for "nicer" URLs, mainly (like example.com/?foo=bar will be example.com/foo/bar or so). Generally speaking, what are some tips & tricks to keep in mind when aiming to optimize the htaccess RewriteEngine? ...

How to enable mod_rewrite for Apache 2.2

I've got fresh install of Apache 2.2 on my Vista machine, everything works fine, except mod rewrite. I've uncommented LoadModule rewrite_module modules/mod_rewrite.s but none of my rewrite rules works, even simple ones like RewriteRule not_found %{DOCUMENT_ROOT}/index.php?page=404 All the rules I'm using are working on my hostin...

301 Redirecting URLs based on GET variables in .htaccess

I have a few messy old URLs like... http://www.example.com/bunch.of/unneeded/crap?opendocument&part=1 http://www.example.com/bunch.of/unneeded/crap?opendocument&part=2 ...that I want to redirect to the newer, cleaner form... http://www.example.com/page.php/welcome http://www.example.com/page.php/prices I understand I can re...

Migrating an existing PHP site to use URL re-writing (Pretty URL's)

I currently have a community site that I run that is made up of 15 or so php pages. It is not currently very dynamic, only using php for includes/templates. Currently no content is generated via a query string. The pages do not follow a standard naming convention and there are many inbound links. I am looking to expand the site (and st...

Creating SubDomains to Absolute Paths with .htaccess

Hey, My host is absolutely terrible. For some odd reason creating a subdomain in cPanel simply does not work, and their support lines are always busy. I thought I could get around this by using .htaccess. I'm sure it's not that hard, but I'm kind of new to mod_rewrite and have had little success searching in the last 5 hours. Heres ...

301 redirect index.html to / or /index.php

Greetings, I have just moved a website from IIS to Apache and am having a little trouble redirecting the index file without causing an infinite loop. Both of these individually will cause a loop- Redirect 301 /index.htm /index.php Redirect 301 /index.htm http://www.foo.com/ Below is a copy of my current .htaccess. Can someone help ...

Mixing RewriteRule and ProxyPass in Apache

I was working on debugging an issue today related to mixing mod_proxy and mod_rewrite together and I ended up having to use balancer://mycluster in the RewriteRule in order to stop receiving a 404 error from Apache. I have two questions: 1) Is there any other way to get the rewritten URL to go through the balancer without adding balance...

Having a CGI script catch all requests to a domain with Apache.

Hi, Using Apache 2, I want to configure my website so that any requests to the domain are forwarded to a Python CGI script. Basically, if the user goes to http://www.example.com i want the cgi /cgi-bin/cgi.py to execute. If the user goes to http://www.example.com/index.rss I want /cgi-bin/cgi.py to be executed with /index.rss as the ar...

How do I 301 redirect one domain to the other if the first has a folder path

I want to 301 redirect from: www.olddomain.com to the root of newdomain.com but I want it to work no matter what the folder path is on the old domain. eg: the following should all redirect to the root of newdomain.com www.olddomain.com olddomain.com www.olddomain.com/folder/file.php olddomain.com/folder/file.php How can I do that with...