.htaccess query regrading a sub-directory in URL and 404 error -



.htaccess query regrading a sub-directory in URL and 404 error -

i have site installed on domain www.mydomain.com/alpha/ [directory can not changed now]

problem 1: redirect request www.mydomain.com www.mydomain.com/alpha/

(once redirection takes place other links should not show alpha in url)

problem 2: other links on site have alpha in url. there way remove alpha before user clicks on link.

problem 3: have site hosted @ www.mydomain.com/alpha2/ should not affected. set next .htaccess , site throwing 404 error.

rewritecond $1 !^alpha/ rewriterule ^(.*)$ /alpha/$1 [l]

changing directory on site have improve performance. if cannot that, can seek adding next .htaccess in root dir of site.

it assumes each site (alpha , alpha2) self contained i.e. resources (css, js etc) in alpha , alpha2 directories respectively. if not true, rules may need adjusting

rewriteengine on rewritebase / ### first 301 redirect /alpha requests without alpha rewritecond %{the_request} ^[a-z]{3,9}\ /alpha(/[^\ ]+) [nc] rewriterule ^ http://%{http_host}%1 [r=301,l] ### next rewrite requests alpha #prevent internal redirects rewritecond %{env:redirect_status} !200 #exclude alpha2 rewritecond %{request_uri} !^/alpha2/ [nc] rewriterule ^ alpha%{request_uri} [l]

this should solve questions 1,3.

is there way remove alpha before user clicks on link.

its more involved, but, yes, can write own filter.

.htaccess

Comments