Good Day
I want to rewrite a url when request a subdirectory
When the user request
172.0.0.1/url
i want to rewrite to make this url point to
172.0.0.1/url/url
or the documentroot is in /var/www/html/url/url make this point to
172.0.0.1/url
2
Answers
You can use
.htaccess
to redirect/url
to/url/url
Just Create .htaccess file at
/var/www/html/
with following contains:This will Redirect all incoming requests at
/url
and redirect them to/url/url
But you cannot redirect requests coming at
/url/url
to/url
Because we are already redirecting request at/url
, this will result in catch 22 and browser will keep redirecting back and forth between/url
and/url/url
.The trick here is to avoid creating a rewrite and a redirect loop. You can put this code in your root folder htaccess