regex - Htaccess rewrite URL with virtual directory and 2 variables -


its url...

result.php?team=arsenal&player=ospina 

i want this

mysite.com/virtualdirectory/arsenal/ospina.html 

i tried code.. cant work.. not found

rewriterule ^(.*)/(.*)/(.*).html$ result.php?team=$2&player=$3 [l] 

the requested url /subfolder/arsenal/ospina.html not found on server.

apache/2.2.8 (win32) php/5.2.6 server @ localhost port 80

thanks helps, best regards!!

ok , assume want change uri from

 http://www.example.com/result.php?team=arsenal&player=ospina 

to

 http://www.example/subdirectory/arsenal/ospina.html 

so .htaccess

rewriteengine on  rewritecond %{query_string} ^team=(.*)\&player=(.*)$  rewriterule ^(.*)$ http://www.example.com/subdirectory/%1/%2.html [r=301] 

you can test htaccess tester here http://htaccess.madewithlove.be/


and useful links documentation , learning:

http://httpd.apache.org/docs/2.2/rewrite/intro.html

http://code.tutsplus.com/tutorials/an-in-depth-guide-to-mod_rewrite-for-apache--net-6708

great video tutorials - understanding apache , htaccess

hope helps


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -