The web server is Apache. I want to rewrite the url so that the user does not know the actual directory. For example: Source 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 located at the root of the site, but when I access the piecework file .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 located at the root of the site, but when I access the piecework file .mydomainname.com / en / 11, I got "Object not found" (of course, I replaced mydomainname with my domain name.)
What's wrong?
source
share