views:

67

answers:

3

Hi, I want to redirect this:

subdom.mydom.com/mydoc

TO

mydom.com/subdom/mydoc.php

Sorry for being too obvious. I know the htaccess rewritting basis but this is making me a little crazy :)

A: 

I’ve never done any mod_rewrite stuff, but I imagine the regexes might look a bit like this:

Match:

([^\.]*).mydom.com/(.*)

Redirect to:

mydom.com/$1/$2.php
Paul D. Waite
A: 

It's been a while, but it would be something like this (assuming you want all /whatever to redirect to /whatever.php):

RewriteEngine On
RewriteRule ^([^\.]+)\.mydom\.com/(.+) mydom.com/$1/$2.php
Håvard S
+3  A: 
RewriteBase /
RewriteCond %{HTTP_HOST} !www.domain.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).domain.com [NC]
RewriteRule (.*) %2/$1 [L]

-- http://www.easymodrewrite.com/example-subdomains

Alex Brasetvik