URL Rewrite with links

ok
i have a link that looks like this

domain.com/site/categories/product1.html

which I want to redirect to

domain.com/site/product1.html

this is what I am currently using to redirect and it's not working

RewriteEngine on
RewriteRule ^([A-Za-z0-9_]+).html$ /site/index.php?page=$1&done_redirect=1
RewriteRule ^([A-Za-z0-9_]+)/([A-Za-z0-9_]+).html$ /site/index.php?page=$1&id=$2&done_redirect=1

RewriteCond %{QUERY_STRING} page=([A-Za-z0-9_]+)
RewriteCond %{QUERY_STRING} !id=([A-Za-z0-9_]+)
RewriteCond %{QUERY_STRING} !done_redirect=1
RewriteRule ^site/index.php$ /1.html? [R]


what happens is

domain.com/site/home.html becomes domain.com/site/index.php?page=home

or

domain.com/site/categories/product1.html becomes domain.com/site/index.php?page=categories&id=product1

that works

the second part is that

domain.com/site/index.php?page=home shows in the address bar as  domain.com/site/home.html

but this bit does't display as I would like

domain.com/site/index.php?page=categories&id=product1 should become

domain.com/site/product1.html

abenbowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

smckellar83Commented:
try this

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /site/index.php?page=$1 [L]
0
abenbowAuthor Commented:
that works for

domain.com/site/link.html

but not for

domain.com/site/categories/product1.html - I get 'page can not be found' which should happen.
0
abenbowAuthor Commented:
sorry

i mean should not happen.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

smckellar83Commented:
add this

RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /site/index.php?page=$1&id=$2&done_redirect=$3 [L]
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abenbowAuthor Commented:
domain.com/site/categories/product1.html

still gives me a page can not be found.

page should be categories.html

(if I use domain.com/site/categories.html that will work)

 
0
abenbowAuthor Commented:
ok

let me try and put it another way

this is the link that the user with click on - /categories/catergory1.html

this is what I would like to be displayed in the address bar /category1.html

and this is what I would like the 'code' to get /index.php?page=categories&id=category1

now it also needs to be able to cope with

this is the link that the user with click on - /page.html

this is what I would like to be displayed in the address bar /page.html

and this is what I would like the 'code' to get /index.php?page=page
0
abenbowAuthor Commented:
ok, forget this I have discovered a problem with my method
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.