php - Using variable in mod_rewrite on redirect -


i have following code, works problem dont want birds hard coded in rewriterule.

rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /birds/$1 [l,r=301] 

i dont want add manually because there many folders "birds"

example:

from

http://domain.com/birds/x.html/ 

to

http://domain.com/birds/x.html 

but in case returns to

http://domain.com/x.html 

you can capture full uri path rewritecond %{request_uri} instead of rewriterule relative current directory:

rewritecond %{request_filename} !-d rewritecond %{request_uri} ^(/.*)/$ rewriterule /$ %1 [l,r=301,ne] 

Comments