Redirecting a Web Folder Directory to another Directory in htaccess
Today, We want to share with you Redirecting a Web Folder Directory to another Directory in htaccess.
In this post we will show you Redirecting a Web Folder Directory to another Directory in htaccess, hear for Redirecting a Web Folder Directory to another Directory in htaccess we will give you demo and example for implement.
In this post, we will learn about Redirecting a Web Folder Directory to another Directory in htaccess with an example.
As a configuration file, .htaccess is very powerful. Even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.
Apache .htaccess 301 redirect is a server side redirect and is a permanent redirect.
The .htaccess file is an Apache server configuration file
The .htaccess file is used per directory.
A permanent 301 redirect in your .htaccess file lets search engines and others know that an old link has been replaced by a new one. It’s the recommended method for directing traffic from an existing page.
# This allows you to redirect your entire website to any other domain
Redirect 301 / https://www.pakainfo.com/
# This allows you to redirect your entire website to any other domain
Redirect 302 / https://www.pakainfo.com/
# This allows you to redirect index.html to a specific subfolder
Redirect /index.html https://www.pakainfo.com/newdirectory/
# Redirect old file path to new file path
Redirect /olddirectory/oldfile.html https://www.pakainfo.com/newdirectory/newfile.html
# Provide Specific Index Page (Set the default handler)
DirectoryIndex index.html
.htaccess redirect
Single URL redirect
Redirect 301 /old-page.html http://www.mydomain.com/new-page.html
Entire domain redirect
Redirect 301 / http://www.newdomain.com/
Enabling .htaccess configuration(httpd.conf:)
AllowOverride All
httpd.conf redirect
$ apache2ctl -M
restart the Apache server after httpd.conf update
$ sudo /etc/init.d/apache2 restart
steps getting to .htaccess file
1: Login to your cPanel.
2: Under Files, click on File Manager.
3: Select the Document Root for: option, and choose your domain from the drop-down.
4: Ensure that Show Hidden Files is selected.
5: Then click Go.(file-manager-hidden-files)
6: Right-click on the .htaccess file and select Edit.(file-manager-htaccess-edit)
7: If your .htaccess file didn’t exist already during the previous step, click on New File at the top-left, name the file .htaccess, and finally set the directory for the file to be created to /public_html/ or the document root of your site.()file-manager-htaccess-create
8: You might have a text editor encoding dialog box pop-up, you can simply click on Edit.
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC] RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
Redirecting within the same domain
RewriteRule ^url-string-to-redirect$ http://www.yourdomain.com/your-new-url-string [R=301,L]
Redirecting to a different domain
RewriteEngine On RewriteCond %{HTTP_HOST} ^olddomain.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.olddomain.com [NC] RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301,NC]
Redirecting WWW to non-WWW with htaccess
RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
We hope you get an idea about Redirecting a Web Folder Directory to another Directory in htaccess
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.
We hope This Post can help you…….Good Luck!.