I'm trying to redirect a folder and all its sub files to a URL with a .htaccess file.
But
Redirect 301 /abc/cba/ http://www.aaa.com/
Will make /abc/cba/ddd/index.html
redirect to http://www.aaa.com/ddd/index.html
What I want is redirect /abc/cba/ /abc/cba/ddd/index.html
to http://www.aaa.com/
Could anyone help? Thanks. If anything not clear, please let me know.
Right-click a folder that you want to redirect (for example, Documents), and then select Properties. In the Properties dialog box, from the Setting box, select Basic - Redirect everyone's folder to the same location.
Use a 301 redirect . htaccess to point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the "example.com" domain.
Redirect "ALL" requests to a domain to a subdirectory You can redirect all requests to a subdirectory by adding an . htaccess file to the root of your domain's directory: Visit the FTP page for instructions on how to upload.
By default, Redirect
sort of maps the path node to a new path node, so anything after the first path gets appended to the target URL.
Try:
RedirectMatch 301 ^/abc/cba/ http://www.aaa.com/?
Or if you'd rather use mod_rewrite instead of mod_alias:
RewriteEngine On RewriteRule ^/?abc/cba/ http://www.aaa.com/? [R=301,L]
here's another example of a mod_rewrite rule that worked for me
I wanted to redirect a sub directory to the root of the same domain.
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^sub_directory/(.*)$ /$1 [R=301,NC,L] </IfModule>
more examples can be found here:http://coolestguidesontheplanet.com/redirecting-a-web-folder-directory-to-another-in-htaccess/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With