I want to redirect website homepage only to subdomain /test, currently I have a header redirect in the index.php file.
Current url is https://www.website.com/test
I want to use .htaccess to mask subdirectory test in url but still want all other requests go to corresponding destination under root.
If test is subdirectory you can try this rewrite in .htaccess file:
RewriteEngine On
RewriteRule ^\/$ /test/ [L]
Related
I need to redirect every URL that requests a file in /subfolder, for example: example.com/subfolder/food/apple.pdf -> example.com
I tried creating a .htaccess inside /subfolder that contains:
RewriteEngine on
RewriteRule ^subfolder/.*$ / [R=301,L]
Unfortunately, without success. Is there a way to achieve this?
apple.pdf and all files inside the /subfolder do not exist anymore (that's why I need a redirect)
I have a site sub.domain1.com
But i would like to access to it from the following url: domain2.com/folder
Here is the .htaccess file in domain2.com
RewriteEngine on
RewriteBase /
RewriteRule ^folder/(.*) http://sub.domain1.com/$1 [L,R=301]
This redirection works well but i wouldn't like to change the url to sub.domain1.com
I want to display the content of sub.domain1.com by using the url domain2.com/folder without changing url.
Thanks in advance
I am moving a Magento site from example.com/shopping to example.com and I have to 301 redirect all of the URLs to the new location (example.com). I am assuming I can use mod_rewrite in the .htaccess file to create a rewrite rule to do this? I tried to learn how to use mod_rewrite, but the syntax is so complex for me.
There are hundreds of pages that need to be redirected. Example:
http://www.example.com/shopping/product-category-1/product-sub-category.html
TO
http://www.example.com/product-category-1/product-sub-category.html
This is so that people don't end up with a 404 error when they enter the site via an old URL.
Try adding this to the htaccess file in your document root, preferably above any rules you may already have there:
RewriteEngine On
RewriteRule ^shopping/(.*)$ /$1 [L]
If you want to redirect the browser so that the new URL appears in the location bar, add an R flag in square brackets:
RewriteEngine On
RewriteRule ^shopping/(.*)$ /$1 [L,R=301]
I'm trying to redirect a few pages to a new domain and I have done this before but for some reason I can't get the code to work.
RewriteEngine On
Redirect 301 http://domain.com/page1.html http://domain2.com/page1.html
Can anyone see where I'm going wrong?
In .htaccess file the below code will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Since you say you only want to direct a FEW of your pages and not all of them, you can do:
RewriteEngine On
Redirect /~myaccount/oldpage.html http://www.newsite.com/newpage.html
You specify the path to the page on your current server followed by the URL to redirect to.
OR you can do:
RedirectMatch 301 ^/oldpage\.html$ http://www.newsite.com/newpage.html
I wish to redirect www.mysite.com/index.html
to
www.mysite.com/
but I do not wish to redirect all addresses with index.html like
www.mysite.com/folder/index.html
to
www.mysite.com/folder/
So, just to redirect first index.html page to root of site.
Add the following to the .htaccess file in the root folder of www.mysite.com
RewriteEngine On
RewriteBase /
# redirect html pages to the root domain
RewriteRule ^index\.html$ / [NC,R,L]