The net server is Apache. I wish to rewrite URL so a person will not be aware of actual directory. For instance: The initial URL:

world wide web.mydomainname.com/en/piecework/piecework.php?piecework_id=11

Expected URL:

piecework.mydomainname.com/en/11

I added the next claims inshtaccess:

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

Obviously I changed mydomainname with my domain title. .htaccess is positioned within the site root, however when I access piecework.mydomainname.com/en/11, I acquired "Object not found".(Obviously I changed mydomainname with my domain title.)

I added the next claims inshtaccess:

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

Obviously I changed mydomainname with my domain title. .htaccess is positioned within the site root, however when I access piecework.mydomainname.com/en/11, I acquired "Object not found".(Obviously I changed mydomainname with my domain title.)

Wrong?

Use RewriteLog inside your vhost or server-conf to be able to look into the spinning process. At this time you simply appear to you know what mod_rewrite does.

By utilizing RewriteLogLevel you are able to customize the extend from the logging. To begin with I'd recommend level 5.

PS: Be sure to reload/restart the server after modifying the config.

You do it backwards. The concept is you can give people the friendly address, and also the re-write rule points demands for this friendly, non-existent page towards the real page without one seeing it. So right now you must it only handling how to proceed once they visit the ugly URL, but you're investing in the friendly URL. since no rule is available when ever people place the friendly URL directly, apache searches for it and states "Object not Found"

So give a line:

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

Sorry, that's quite right, however the fundamental idea is, when they make the URL you want, Apache is able to redirect towards the real page with no browser seeing it.

Update

I am method to sleepy to complete regex properly, and so i had just attempted my better to move your example around, sorry. I'd try some thing simple first just to obtain the fundamental concept lower first. Do this:

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

At the minimum, it will likely be simpler to determine what is not working when you get errors.

Here is a quick summary of what is happening:

RewriteCond %{HTTP_HOST} ^(?!www)([^.]+)\.mydomainname\.com$ [NC]

First, the question mark should be in the finish.

$1 would (should) match anything that's not 'www' or 1 occasions.

$2 matches anything that's not really a character 1 or even more occasions, which theoretically would match an empty space there but likely would not match anything.

It requires '.mydomainname.com' after individuals two types.

The first two the weather is searching for two separate types.

I am unsure just how you are trying to setup your structure, but this is how I'd write it according to your original and expected URL's:

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

Essentially, the first condition would be to make certain it isn't the URL starting with 'www' (it's simpler to simply turn it into a separate rule). The 2nd condition causes it to be check any word that may be before your domain title. Your rewrite rule will redirect it properly.

Eliminate the final .htaccess line there inside your question...

Someone please correct me basically typed a problem. I do not remember if you need to possess the '' before 'w' and 'd' however i incorporated them anyways.