steven2 0 Newbie Poster

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.)

Then I removed the aforementioned lines and 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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.