Aditya_18 0 Newbie Poster

Hi, I want to redirect my sub doamin blog.adityabevoor.com to a folder called blog. I need apache directives to edit .htaccess file. can you help me out please? Thanks

Dani AI

Generated

For : two common goals are either (A) keep the address bar as blog.adityabevoor.com while serving files from the /blog folder (internal rewrite), or (B) send visitors to adityabevoor.com/blog so the browser shows the folder (external redirect). Both can be done with .htaccess, but the recommended production approach is a dedicated Apache VirtualHost for the subdomain.

Internal rewrite (URL stays blog.adityabevoor.com; place this .htaccess in the main DocumentRoot, not inside /blog):

RewriteEngine On

# only for the blog subdomain
RewriteCond %{HTTP_HOST} ^blog\.adityabevoor\.com$ [NC]
# avoid looping when /blog/ is already in the request
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [L,QSA]

Visible redirect (browser is redirected to adityabevoor.com/blog; use 301 for permanent moves and change to https if applicable):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.adityabevoor\.com$ [NC]
RewriteRule ^(.*)$ https://adityabevoor.com/blog/$1 [L,R=301,QSA]

Preferred server-side VirtualHost (better separation, performance, easier TLS):

<VirtualHost *:80>
    ServerName blog.adityabevoor.com
    DocumentRoot /var/www/adityabevoor/blog
    <Directory /var/www/adityabevoor/blog>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Notes and troubleshooting: ensure DNS for blog.adityabevoor.com points to the server (A or CNAME), enable mod_rewrite (check with apachectl -M | grep rewrite), and make sure the vhost allows .htaccess (AllowOverride All) if using it. If HTTPS is used, the certificate must cover the subdomain. If the blog is a CMS (WordPress, etc.), internal rewrites may require adjusting site URLs or permalink settings. Check Apache error/access logs (typical paths: /var/log/apache2/ or /var/log/httpd/) when behavior is unexpected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.