URL rewriting with mod_rewrite

Posted by Steven on Stack Overflow See other posts from Stack Overflow or by Steven
Published on 2010-03-18T02:56:16Z Indexed on 2010/03/18 3:01 UTC
Read the original article Hit count: 796

The web server is Apache. I want to rewrite URL so a user won't know the actual directory. For example: The original URL:

www.mydomainname.com/en/piecework/piecework.php?piecework_id=11

Expected URL:

piecework.mydomainname.com/en/11

I added the following statements in .htaccess:

RewriteCond %{HTTP_HOST} ^(?!www)([^.]+)\.mydomainname\.com$ [NC]
RewriteRule ^(w+)/(\d+)$ /$1/%1/%1.php?%1_id=$2 [L]

Of course I replaced mydomainname with my domain name. .htaccess is placed in the site root, but when I access piecework.mydomainname.com/en/11, I got "Object not found".(Of course I replaced mydomainname with my domain name.)

I added the following statements in .htaccess:

RewriteRule ^/(.*)/en/piecework/(.*)piecework_id=([0-9]+)(.*) piecework.mydomainname.com/en/$3

Of course I replaced mydomainname with my domain name. .htaccess is placed in the site root, but when I access piecework.mydomainname.com/en/11, I got "Object not found".(Of course I replaced mydomainname with my domain name.)

What's wrong?

© Stack Overflow or respective owner

Related posts about apache

Related posts about .htaccess