Hi I tried the following in the kodekloud engineer lab 1 in linux leve3:
I adjust in the /etc/httpd/conf/httpd.conf the following:
Listen 3002
In the <directory /var/www/html> I set AllowOverride to All to be able to use .htaccess
Then I went to the /var/www/html folder and create the news folder, since is not already made in the lab by default, the I copied the content of the blog folder in /var/www/html in the /var/www/html/news/ So I can have a subdirectory page in the webpage that is called news. Then I created the .htaccess in the /var/www/html folder with the following:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/blog(/.*)?$
RewriteRule ^(.*)$ /news [L,R=302]
I also tested with this one, in the case that the redirection should not work with post in the blog subdirectory, for example: /blog/post1 —> /news/post1 and so on and so on:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/blog$
RewriteRule ^(.*)$ /news [L,R=302]
Then just sudo systemctl restart httpd to see that httpd is working fine. Then I checked with curl -I and curl -L to see the redirect, which is the case, with the following outputs:
curl -I http://stapp03.stratos.xfusioncorp.com:3002
HTTP/1.1 301 Moved Permanently
Date: Sat, 19 Jul 2025 16:44:44 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.2.26
Location: http://www.stapp03.stratos.xfusioncorp.com:3002/
Content-Type: text/html; charset=iso-8859-1
curl -L http://stapp03.stratos.xfusioncorp.com:3002
Welcome to the Nautilus Group!
curl -I http://www.stapp03.stratos.xfusioncorp.com:3002/blog
HTTP/1.1 302 Found
Date: Sat, 19 Jul 2025 16:46:11 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.2.26
Location: http://www.stapp03.stratos.xfusioncorp.com:3002/news
Content-Type: text/html; charset=iso-8859-1
curl -L http://www.stapp03.stratos.xfusioncorp.com:3002/blog
Welcome to the Nautilus Group Blog!
So everything seems right. The redirections are working as you can see with the both curl commands being made. The output of the lab is the following:
seems like /blog is not redirecting to /news on App Server 3 or its not a temporary redirect
but that’s is not the case as you can see, the outputs are sent correctly as you can notice with the curl commands. I don’t get it, please check this, it’s working, or at least there are missing information to complete this lab well.
BTW, not sure why but the code commentary with markdown is not working well in this post, sorry about that, I had all well formatted but in order to send it it was imposible. It send me error 403.
Might be that you need to use > instead of triple-ticks:
So everything seems right. The redirections are working as you can see with the both curl commands being made. The output of the lab is the following:
sorry I don’t get it. what does this > mean with the solution of the lab ? or are you telling me that in relation with the syntax of markdown in my post?
Did you checked the lab ? Because as I can see everything seems fine for the requirements of the solution.
Talking about the markdown. ‘>’ starts a block of wrapped text. I haven’t checked your lab; I don’t do much with KK Eng, since there are folks in the group that have worked their way through it; I specialize in other topics.
thansk @rob_kodekloud for the answer
. I’ll be more than glad If you can tell your KK Eng folks about my issue to get an answer quickly 