php - Pages in subdirectory redirect only to that subdirectory -


i have site in 2 directories, default on root , other root/en. there way tell in .htaccess every link click on root/en version redirects root/en?

for example have link on default installation leads root/news. if user located on root/en , clicks link redirects him root/en/news.

we have /en prefix before our original links. or have go , change links manually?

rewrite won't work or extemely complex because have same files in both directories. apache won't know how tell link clicked unless change links. quick way change base url links in pages use <base> tag. note change base url relative resources such css, javascript , images too.

if links in pages relative (i.e. don't have http://www.example.com part), can use <base> tag set base url resources on page. see: http://www.w3schools.com/tags/tag_base.asp

all of pages in /en/ directory should have <base> tag sets base url, , links should start /.

example:

<html>    <head>      <base href="http://example.com/en/">    </head>    <body>      <a href="/news.php">news</a>    </body>  </html>

here's example of apache redirect subdirectory, don't think works in yoru case. browsers not able access in / directory way:

rewriteengine on rewriterule ^$ en [l]     

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

qt - How to embed QML toolbar and menubar into QMainWindow -