apache - Redirect/htaccess without folder name -


i have simple issue in redirecting web site folder link. have main domain , lets abc.com , have subdomain xyz.com. have xyz.com in document root folder of abc.com , folder name othersite. works perfect, when type manually in browser www.xyz.com/hero , takes m tot hat directory url changes in browser , shows me www.xyz.com/othersite/hero. not sure why doing so, works when type www.xyz.com/hero/ , i.e. / @ end.

here have in main htaccess in abc.com htaccess

rewriteengine on options +followsymlinks  rewritebase /  rewritecond %{http_host} ^xyz\.com$ [or]  rewritecond %{http_host} ^www\.xyz\.com$ rewritecond %{request_uri} !^/othersite/  rewriterule ^(.*)$ othersite/$1 

this because mod_dir turned on , automatically redirect requests directories missing trailing slash include trailing slash. there's information disclosure security risk when don't this:

turning off trailing slash redirect may result in information disclosure. consider situation mod_autoindex active (options +indexes) , directoryindex set valid resource (say, index.html) , there's no other special handler defined url. in case request trailing slash show index.html file. but request without trailing slash list directory contents.

so can turn off auto-redirecting including:

directoryslash off 

if don't care issue of displaying directory's contents instead of index file. alternatively, can perform redirect before internal rewrite make sure there's trailing slash without exposing internals:

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

then rest of rules.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -