.htaccess - How to rewrite url in htaccess without redirecting on localhost? -


trying ask question again , explain best can.

i running wamp on windows 10. apache version 2.4.18. project in www folder named hoidja.ee. mod_rewrite enabled, allowoverrideis set all.

inside folder have .htaccess file, trying accomplish rewrite without redirect , not work @ all. know .htaccess file working, since can rewrite index.php /home/ example , working fine.

i have page users listing. can click on user, , take url:

http://localhost/hoidja.ee/hoidja.php?user_id=94&username=john

how show is

http://localhost/hoidja.ee/user/john 

without redirection.

what have tried:

#tried first user_id rewritecond %{query_string} ^user_id=([a-za-z0-9-]+)$ rewriterule ^hoidja\.php$ /user/%1? [l] 

this gave me 404 /user/94 doesn't exist.

rewriterule ^user/([0-9]+)/([a-za-z0-9-]+)/?$ hoidja.php?user_id=$1&username=$2 [qsa] 

this doesn't visually. if enter http://localhost/hoidja.ee/user/94/john in url manually, goes page , shows user data, if enter original url not rewrite it. using <base> well.

i have tried possible ways nothing seems work. how can accomplish url rewrite?

you getting 404 error because rewriting non-existent path /user/94 .you need redirect /hoidja.php?user_id= /user/94 , rewrite /user/94 real location.

rewritecond %{env:redirect_status} !200 rewritecond %{query_string} ^user_id=([a-za-z0-9-]+)$ rewriterule hoidja\.php$ /hoidja.ee/user/%1? [l,r] rewriterule ^(?:hoidja\.ee/)?user/(.+)$ /hoidja.ee/hoidja.php?user_id=$1 [l] 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -