mod-rewrite

Conditional .htaccess rules for same URL

What is the best method to combine the following two rules into one, so that users can visit domain.com/schedule and also domain.com/schedule/{day} The rule should forward to the same controller, where I will then check the parameter RewriteRule ^schedule/?$ index.php?_orn_shows_action=view-schedule [NC,QSA,L] RewriteRule ^schedule/([a...

Alias Domain to Zend Directory

I have a ZF website at domainA.com and I'd like to alias domainB.com to something like: domainA.com/photos/album so that album would be the root of domainB. How might this be accomplished? ...

How does RewriteRule work?

I just don't get it: Options +FollowSymlinks -MultiViews RewriteEngine on RewriteBase / RewriteRule ^([a-z]+\-[0-9]+)/?$ $1/home/ [R] RewriteRule ^[a-z]+\-([0-9]+)/(home|alone)/?$ /$2.php?id=$1 [L] RewriteRule ^.*$ http://www.anotherdomain.com/ [R=301] why is the last rule (and by last I mean the redirection to anotherdomain.com) alw...

Domain based redirect to different PHP files via htaccess

Domain based redirect to different PHP files via htaccess Hello there. Here's the thing: I have two domains here [http://www.myproject.com and [http://www.myproject.com.br .. In my root folder i have all the stuff for my projects including two "indexes": "index-en.php" for english and "index.php" for portuguese. Can i have some trick...

how to redirect request based wether a query string value is present?

Hi, I've searched and tried many examples but none seem to work for me. I need to redirect a request to a specific url depending on if the original request had a certain item in it's query string. e.g. www.mydomain.com/test.html?username=foo&password=bar So I want to redirect this only is the username variable is present in the query...

HTaccess rewrite rule

Hi all. I have a webpage http://mydomain.com/form.php?id=123 , I need to keep this format for old functionality , and to implement a new functionality so the user could access this page like this http://mydomain.com/123. So the client will see this http://mydomain.com/123. And the server will understand as old version http://mydomain....

Apache mod_rewrite: RewriteMap directive using PHP script on Windows machine

This has been driving me insane. I can't seem to get the RewriteMap directive to work for a php script on windows. Here is the relevant snippet from my httpd.conf file: <IfModule mod_rewrite.c> RewriteEngine on RewriteMap router "prg:C:/dev/web/www/routing.php" RewriteRule (.*) ${router:$1} </IfModule> My simpl...

mod_rewrite newbie needs help with (simple?) rewrite rule

I tried. I failed. Here's what I want to do: Using firebug I saw that the GET string in the request header for my stylesheets and other content was being munged by the application (which I can't modify). I think a simple rewrite rule might help but I can't get it to work. Here's what I need: input: /content/2010/08/forum/styles/...

.htaccess make folder act as root?

Hi, Is there a way to make .htaccess tell a folder to act as the lowest level? What I mean is this, say you have a folder like so: /about/ /contact/ /css/ /images/ .htaccess index.php header.php If they are at /contact/index.php, then if I have <a href="../index.php">Home</a> to go to the home page, it works all fine, but if they a...

Links with WWW in Wordpress redirect to home page

I've recently updated a website I work on to Wordpress 3.0. Something strange has started happening, where now the www. has dissapeared from the URLs, and if you add the www. to the URL (a good portion of the existing hardcoded links have it) then it redirects you to the home page URL. Any ideas what could be causing this? My .htaccess...

mod_rewrite - convert querystring to paths

Im trying to rewrite a url that has a query string to its SEO friendly name i.e. consider mysite.com/models?p1=v1&p2=v2&p3=v3&p4=v4&p5=v5&p6=v6 Id like it to rewrite to mysite.com/models/v1/v2/v3/v4/v5/v6 or mysite.com/models~v1~v2~v3~v4~v5~v6 whichever works better for SEO. any suggestions j ...

mod rewrite issues with php

These should be a relatively easy task but I am having some serious issues with my muddled head on a friday. I have: http://www.localokel.com/search.php?sch=city&amp;val=London and am trying to get: http://www.localokel.com/search/city/London Currently the following is not working: RewriteEngine On RewriteRule ^([^/]*)/([^/]*)$ /s...

mod_rewrite - convert paths to querystring

consider this rule RewriteRule ^/models/(.*)/(.*)$ /models?$1=$2 [NC,L] this rewrites /models/application/lawnmower to /models?appliction=lawnmower nice, just what i want now consider this rule (there are up to 6 name/value pairs) RewriteRule ^/models/(.*)/(.*)/(.*)/(.*)$ /models?$1=$2&$3=$4 [NC,L] this should rewrite /...

301 Redirect from main domain (www and non-www) to subdomain

I need to redirect from a main domain like mydomain.com or www.mydomain.com to sub.mydomain.com - and this needs to work for all requests, so mydomain.com/whatever goes to sub.mydomain.com/whatever. I've tried this, which only works for non-www at the main domain: RewriteCond %{HTTP_HOST} ^mydomain.com [NC] RewriteRule ^(.*)$ http://su...

Problem creating friendly SEO URLs on local server

I'm having problems implementing friendly SEO urls on my local (Mac OS X Snow Leopard) development server. *Note: site.com is just an example (1) Currently my site's root is set up with a virtual host pointing to a sub-directory of my Sites folder. (2) Pages are currently being accessed in the following format: http://site.com/index.p...

How to rewrite http root depending on development / production environment (htaccess question)

Hello, I have a development box which contains my site in: http://localhost/dev/ My production environment is just: http://mydomain.com/ I have all my PHP scripts adjusting to different paths automatically, but everytime I upload changes to my .htaccess file, I need to manually change any mentions of my http_root directory "/dev/"...

Redirecting with mod_rewrite?

So I have a webpage that queries some data based on this parameter search.php?state=AL. What I'm trying to do is write a rule in my .htaccess file that will: translate website.com/state/AL into search.php?state=AL If a user specifically request search.php?state=AL then translate that into /state/AL I accomplished step 1 using thi...

.htaccess redirect from GET variable to url string

I need to redirect... /search?keywords=somesearchterm to... /search/somesearchterm This seems incredibly basic but I've been pounding my head against it for an hour. Thanks for taking the time to look at this. ...

mod_rewrite not working in top directory but OK in subdirectories

I've used mod_rewrite (sparingly) in a few directories before without problems by putting in a .htaccess file for that directory, and it works there now. But when I try to use it in my top level directory, nothing happens!?!?! But that .htaccess file (top level one) is working fine otherwise. I have Redirect 301's and a variety of oth...

Mod_rewrite to SHOW a redirect from a wildcard domain

I am so about to kick mod_rewrite to the curb. Talk about "doesn't play well with others." Are there any witchdoctors about that can help me with this? I have wildcard dns set up to identify users. I would like to go from: http://username.domain.com/foo/bar to: https://www.domain.com/qux/waldo/username/foo/bar Is this possible? I'm...