text:
Setting up a permanent 301 redirect via .htaccess
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.
Some common uses of a 301 .htaccess redirect:
Redirect individual files on the same domain
An old file has moved locations, or the information is now contained in a new file.
Redirect an old domain to a new domain
You've moved a website from an old domain to a new one, and you want any old links to go to the new site.
Force www. version of domain to be used or you can force non www. version of domain to be used
Visitors access and link to your website in multiple ways such as example.com, and www.example.com and you can set one as the preferred method that your site displays.
Redirect all files with certain extension
You used to have all of your files using an extension like .php and have converted everything to .htm so using a 301 redirect you can update all links to use the new extension.
You have the ability to setup redirects for a domain in your cPanel interface one at a time, or following the steps below you can modify your .htaccess file directly to add these manually yourself.
Getting to your .htaccess file
On a Linux server you would use your .htaccess file to implement a 301 redirect for your pages.
- Login to your cPanel.
- Under Files, click on File Manager.
- Select the Document Root for: option, and choose your domain from the drop-down.
- Ensure that Show Hidden Files is selected.
- Then click Go.
- Right-click on the .htaccess file and select Edit.
- 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.
- You might have a text editor encoding dialog box pop-up, you can simply click on Edit.
Redirect individual files
To redirect individual files, like example.com/oldfile.htm to newfile.htm you can use a 301 redirect like this:
Redirect 301 /oldfile.htm /newfile.htm
To redirect one specific file to another domain such as example.com/oldfile.htm to example.net/newfile.htm:
Redirect 301 /oldfile.htm http://example.net/newfile.htm
Redirect an old domain to a new domain
If you had an old domain such as example.com, and now you decided you actually want to use example.net for the website. You could setup a 301 redirect for the entire domain, so that old links to example.com carry over.
Code in the example.com domain's .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]
Force www. version of domain to be used
A search engine like Google would see example.com and www.example.com as essentially two separate websites. They recommend you pick one version you'd like search engines to display and using a 301 redirect is a possible option.
If you have a lot of links on the web where people are linking to your site as example.com, but you would like your visitors to instead end up at www.example.com you can force this version of your domain with these rules:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]
Force non www. version of domain to be used
If you have a lot of links on the web where people are linking to your site as www.example.com, but you would like your visitors to instead end up at example.com you can force this version of your domain with these rules:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301,NC]
Redirect all files with certain extension
To re-direct all of one type of file to another, such as example.com/file.php to example.com/file.htm
RewriteEngine On
RewriteCond %{REQUEST_URI} .php$
RewriteRule ^(.*).php$ /$1.htm [R=301,L]
You should now know how to properly setup 301 permanent redirects on your website to help ensure that search engines and visitors coming to your site from older links can still get to your new content.
Support Center Login
Social Media Login
Related Questions
2014-05-03 11:01 am
Need a solution to this, not addressed above. Want to redirect all "example.com/shop" to "www.example.com/shop" pages. Our SSL certificate covers "www" pages on our shopping cart (i.e. "www.example.com" not "example.com"). On occasion, customers will try to go to a cart page without the "www" prefix and get a warning notice because certificate doesn't cover those pages. Cart settings usually force the "www" but occasionally fail and/or need to be reset.
Have tried to create a redirect, but keep getting "loop" errors. Above discussion doesn't address this specifically. Any help would be appreciated.
2014-05-05 8:57 am
Hello Raplh,
Thank you for your question. We have a general guide on How to force www or non-www in htaccess.
What program are you using to build your website? Depending on your CMS, you may a have to accomplish this a different way. For example, in Wordpress, you would change the site URL from http://example.com to https://www.example.com.
If you have any further questions, feel free to post them below.
Thank you,
2014-09-19 6:23 am
If i enter www.domain.com then must i have www.domain.net aswell ? or only it rewirte and use my www.domain.com's root ?
Please solve my confusion..
2014-09-19 8:42 am
You do not have to own both .net and .com. However if you want to have .net redirect to .com or vice versa, then you will need to own both domains.
Kindest Regards,
Scott M
2014-06-08 12:48 pm
Please provide me solution
I want to redirect my site from
For all my websites link
Please Please Please
Iam stucked
2014-06-09 12:16 pm
Hello Pardeep,
If you are simply wanting to redirect the .net to the .com, you will want to follow the instructions for redirecting from old domain to a new domain. You can simply add the /in-our-markets/ to the end of the domain names to assist with the redirects.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com\/subfolder [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com\/subfolder [NC]
RewriteRule ^(.*)$ http:\/\/example\.net\/subfolder\/$1 [L,R=301,NC]
Kindest Regards,
Scott M
2014-06-13 8:19 am
Thanks, it helped me a lot.... I wanted to redirect all old links from asp pages to php pages, and the article "Redirect all files with certain extension" almost worked, except that it would redirect to the root site for links within subfolders...
for eg: i would like to redirect http://examplesite.ext/sub/page1.asp to http://example.ext/sub/page1.php
But the code shown here redirects to http://example.ext/page1.php
please help
2014-06-13 9:15 am
The following code will allow you to redirect but keep the folder structure:
RedirectMatch 301 (.*)\.asp$ http://www.example.com$1.php
2014-10-02 2:31 pm
Having an issue with this on inmotionhosting.com servers
if I use this RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ /page.php?c=$1&t=$2
the url in the browser shows www.mysite.com/Category/Pagetitle which is what I want
When I add the 301 like thisRewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ /page.php?c=$1&t=$2 [R=301,L]
the url in the browser shows www.mysite.com/page.php?c=Category&t=Pagetitle
this is not what I want.
How do I keep file stucture correct in the browser window as well as making it a 301 on inmotionhosting server?
2014-10-23 5:40 pm
Hello sean,
Thank you for contacting us today. We are happy to help, but need some additional information.
What are you trying to accomplish by adding the 301 redirect?
Thank you,
2014-06-18 10:51 pm
I want to move my site from a nation domain to .com domain, could you suggest me to do it.
it's is www.lacda.vn and move to www.muhato.com
2014-06-19 8:22 am
You would simply need to buy the new domain if you have not already, and add it to your cPanel as an addon domain or perform a primary domain change on your account. Depending on how your site is built, you may also need to make some additional configuration changes if anything is referencing the old domain directly.
2014-06-30 3:06 pm
Good afternoon,
I have create some subdomains for my basic domain. Because I have an SSL card only for principal store, I want that the all login page, registered page and sign-up page and check-out page from all sub-domains to be redirect on basic store. Some example of links are:
- https://mysite.com/login.html (login page from basic store)
- http://sub-domain-1.mysite.com/login.html (login for sub-domain 1, corresponding to login page)
- http://sub-domain-1.mysite.com/?route=account/signup (signup for sub-domain 1, corresponding to signup page)
- http://sub-domain-1.mysite.com/create-account.html (register for sub-domain 1, corresponding to register page)
- https://mysite.com/checkout.html (check-out page from basic store);
Also, I observe that on my home page from basic store don´t appear https on browsers. How I can allow to appear https on home page, also using .httaccess file?
Thank you very much for your advice and support.
I waiting your advice.
Best regards.
P.S. I use OpenCart 1.5.6, multi-store (under the same admin, multiple stores)
2014-06-30 4:19 pm
Hello Johnny P,
SSL certificates are made to work with a specific URL. So, if you order it to go to "https://mysite.com", then all sites in that URL should be secure. However, since you're using a different URL than what was specified for the SSL, the certificate does not protect it. The URL that you mentioned above (sub-domain-1.mysite.com/login.html ) will not work because it is not formatted for the SSL that was purchased. However, there is a way to use the subdomains in this way as long as they are using the primary domain.
If you were to use a Wildcard SSL (you would have to specify that during the purchase of the SSL), then you could use the subdomain format that you're using:
However, if you're using 2 different URLs (you mentioned a principal store and a basic store), the SSL will not work that way. You would definitely need to purchase 2 different SSL certificates.
I hope that helps to clarify the answer. Please let us know if you require any further assistance.
Arnel C.
2014-06-30 11:54 pm
Good morning,
Thank you for answer Arn.
I know this basic detail reffering to SSL Wildcard. Fortunately, OpenCart share the same details for all their sub-domains. This Is the reason because only I want to redirect some basic links (such I specified anterior). When somebody want to login on my some sub-domains, than automatic will be redirected on the corresponding page from basic store (is the same think as principal store, but in other words).
I can redirect those link using file 301 and htaccess? What is the command line which I can add it to ensure redirection? Also I don´t have in my ftp the 301 file.
Thank you for support and advice to all comunity.
I waiting your answer.
Best regards.
2014-07-01 9:10 am
Hello JohnnyP,
If I am correct, you are asking if it is possible to redirect http://login.example.com to https://example.com/login. This can absolutely be done via the htaccess file, but it can be done even easier via the redirect tool for cPanel. This writes the .htaccess code for you. I have tested this on my own server and it worked perfectly.
Kindest Regards,
Scott M
2014-07-01 12:54 pm
I moved my site from ASP to WordPress an I need to redirect any .asp page to the site root. I tried with this code but it doesn't work
RewriteEngine On RewriteCond %{REQUEST_URI} .asp$ RewriteRule ^(.*).asp$ /$ [R=301,L]
Any help will be welcomed
2014-07-01 2:58 pm
Hello Ciro,
You would more than likely want to insert your rewrite rule inside the default WordPress .htaccess rules like this:
# BEGIN WordPress
Please let us know if that is working for you.
- Jacob
2014-07-02 4:32 pm
Thanks Jacob!
2014-07-02 6:03 pm
Hello Ciro,
No problem at all, glad to help out!
Taking a closer look at this, it looks like I might have given those rules to you in haste. While it does seem to technically force all requests for a .asp page to your main WordPress page, it looks like it also possibly breaks the inclusion of CSS files and images.
So you would want to use the redirect code above your default WordPress rules like this instead:
RewriteEngine On
Also as I've answered Heidy's question below about the SEO impact of directing old URLs to new ones. You might also want to think about directly setting up a 301 redirect if you've got the same content just in WordPress now.
Redirect 301 /helpful-page.asp /helpful-page
Please let us know if this works out for you!
- Jacob
2014-07-02 1:46 pm
I appreciate very much your help to solve the following issue.
There is already a live site created long ago in Dreamweaver with .htm and .html files. Recently, I created a completely new site with Joomla 2.5 in a subdirectory under the same root directory of the old site. My intention now is:
1) Redirect all trafic to the subdirectory where I have the new joomla site, using the same domain.
2) I will keep the old site as it is, but I need to redirect old .html and .htm pages to the new corresponding pages in joomla 2.5 to avoid loosing ranking position in search engines.
3) I am concern that redirecting old pages to new pages would be a bad practice for search engines like Google. I want to make sure that this will not be a problem, and if it is, then what it is the correct way for doing it.
I appreciate your help and explain how to do the above.
Thank you very much.
2014-07-02 3:58 pm
Hello Heidy,
Luckily you can redirect your old .htm and .html pages to your new Joomla site, and won't lose any search engine ranking in the process when done correctly.
Search engines use the 301 redirect from a server to update their indexes to make sure they link to your fresh content. Search engines love it when you let them know a old helpful page can now be found at a new home. It helps their users get the most relevant and up to date content, and lets the search engine know you have someone maintaining your site and updating things.
Here is a great page from Google on 301 redirects and why you want to make sure to use it when updating your content. Hopefully that will help put you a little bit at rest for worrying about search engines not liking you updating your links.
Now do keep in mind from a SEO or Search Engine Optimization stand-point, if you're getting a lot of traffic to your HTML page about "how to use a PC". Then you go and completely change the content that was in your HTML page on the Joomla version, for instance you update it with tips on "how to use a Mac" and removed some of the PC information you had before. Over time you could lose ranking for the "how to use a PC" keyword phrase, because search engines care about relevant content and the reason people used to click on your page from Google results might not be there anymore.
To redirect all of your old HTML pages to your new Joomla subdirectory, you would simply edit your .htaccess file and use one of the following formats:
Redirect 301 /helpful-page.htm /joomla/helpful-page
Or include the full URL:
Redirect 301 /helpful-page.htm http://example.com/joomla/helpful-page
I hope that helps, and if you have any further questions at all, please let us know!
- Jacob
2014-09-27 12:23 am
Great post and I read the conversation but unfortunately as far as I can see my question has not been answered.
My site structure changed so now the paths are different. Does this command also work for changed paths?
Redirect 301 /natural-hairstyles /black-natural-hairstyles
2014-10-23 3:43 pm
Hello simplesite,
Thank you for contacting us. The code you provided will redirect people trying to access the /natural-hairstyles folder, to the /black-natural-hairstyles folder instead.
If this is what you want to accomplish, it is correct. If this is not what you are trying to do please provide more details on your goal.
Thank you,
2014-07-02 4:29 pm
No problem Heidy, thanks for stopping by and commenting on my guide :)
2014-07-07 10:35 am
How can i redirect joomla subdirectory to article ? Like mypage.com/subdir -> mypage.com/index.php/article=1
2014-07-07 10:49 am
Hello Punkel,
The best way to do that would be to use the cPanel redirect tool. It will write the code for you and place it into your .htaccess file.
Kindest Regards,
Scott M
2014-07-07 3:36 pm
Thank you, but my site does not have cPanel. Can you paste here .htaccess example?
2014-07-07 3:50 pm
Hello Punkel,
You would simply add this towards the top of your .htaccess file:
Redirect 301 /subdir /index.php/article=1
However further down the file, you'll need something that handles the rewrite of that /index.php/article=1 to actually do something. As article=1 is not a valid URL when just used like that as it would essentially be the same as requesting /folder-name=1 and most of the time you aren't going to have a folder or file with a = symbol in it.
Typically you're going the reverse where you want to go from a URL like /index.php?article=1 and make it a search engine friendly URL like just /page-name.
- Jacob
2014-07-08 1:59 am
Thank you a lot, this Redirect 301 /subdir /index.php/article=1
works perfectly. I use this redirect only for search bots.
2014-07-08 2:10 am
Hello Punkel,
Awesome, glad that helped! It's still a little odd to see a search friendly URL being converted back to a numbering system. So if you happen to be trying to block bad bots for some reason with this redirect, you would find my guide on block users with .htaccess helpful, or even how to identify bad bots.
I hope you're not having a malicious bot issue, and just need to redirect to that URL format for some other reason instead. If so, again I'm glad it helped!
- Jacob
2014-07-08 1:26 am
Good Morning
My Site is single page site that's and my Domain is http://example.com/#!/ and i have to convert this domain to http://example.com using 301 redirect then which code i have to use?
2014-07-08 3:00 am
Hello Rinku,
You wouldn't be able to use a 301 redirect, or to my knowledge any RewriteRule rule to be able to alter the URL like that.
If you hit Ctrl-U in your web-browser you can see the HTML of your page, and you should notice this on the 4th line:
!-- Mirrored from example.com/index.html by HTTrack Website Copier/3.x
So it looks like this one page website might have been copied from another server, and in doing so, looks like it retained a bunch of links including #! already for switching to multiple pages of info when a link is clicked.
It looks like your /js/switcher.js file is responsible for this:
Hope that helps, please let us know if you had any further questions.
- Jacob
2014-07-16 4:20 am
My website opening with "www" and without "www" -- I want my website always open without "www" if some one open with "www" it should be redirect in without "www" - please inform me - how can i solve this problem - website made in PHP . thanks
2014-07-21 7:21 pm
Hello Shashi,
You can use the .htaccess rules mentioned above from the force non www example in this guide:
RewriteEngine on
This will force all requests for www.example.com to instead just redirect to example.com without the preceding www at the beginning of the domain.
Please let us know if you needed anything else at all.
- Jacob
2014-07-28 5:05 pm
stop creating cartoons and create a text-only step-by-step version
2014-08-01 3:29 pm
Hello Stu, and thank you for your suggestion.
There are already many text-only versions out there that cover 301 redirects on the Internet, was there a specific way of redirecting you were unable to figure out by following the current text with animations on this guide?
In my experience I've found that most people when they are writing rewrite code want to know what the end result is going to do in their web-browser. I thought there would be no better way to show that then literally showing what happens when you activate a particular rewrite rule and then watch it in the browser to see what it does.
- Jacob
2014-08-01 3:34 pm
Hello shregs, and thanks for your comment,
Was there any particular examples you were looking for, or what in your opinion could use more explanation to be easier to understand?
- Jacob
2014-08-01 3:21 pm
I have a website that I am working on that had multiple domain names because we have multiple companies. They were all leading to the same website, but with different URL addresses. I didn't want a duplicate content issue, so I redirected all of the multiple domain names to the main website name since we rebranded about 6 years ago and the last webmaster didn't do any 301 redirects from the old domain to the new one. I am also trying to get the link juice from those domains and recover the history of the last domain because we still own it and it's 15 years old as opposed to the current domain that is 6 years old. Will Google penalize me for doing this or is this the positive step for my SEO? Also, do you know how long it will take to get the history of old domain to merge with our newer domain? Any help is apprecaited
2014-08-01 3:58 pm
Hello Joy,
It would really depend on the niche that your website is in, but for the most part having multiple domain names pointing to the same website content is not going to help you SEO wise. In some cases it can hurt you by getting penalized for duplicate content as described by Google.
It would help to get a better understanding of exactly what you're trying to do before we could offer an real recommendation as to what you might want to do. I'd recommend checking out the Google Webmasters page about change page URLs with 301 redirects it also has a good video on it from Matt Cutts at Google talking about when you might want to use a 301 redirect.
In order to get link juice from an old domain, if you had a page like example.com/how-to-tie-a-tie that was ranking well for the search query how to tie a tie, then you'd want to make sure that you're passing on that ranking to your new domain with a 301 redirect. So you would have it go to a matching URL on your new domain such as example.net/how-to-tie-a-tie that also contains related info to what the old domain had been ranking for.
In regards to your questions about older and newer domains, those don't really hold as much weight as they use to in the SEO world. It's really more about the content of your website as opposed to the domain they are hosted on. If you're currently ranking high for something on a newer domain, setting up a 301 redirect for it to now be on an older domain isn't going to really give you much of a boost if any at all.
If you can be more specific in your question with examples of exactly what you're attempting to do we can attempt to provide you a better answer for your specific situation.
- Jacob
2014-08-01 4:18 pm
Thanks Jacob,
I already read everything that I could find about it. I am not talking about recovering pages since our old website is long gone as are the pages and I don't know the page names or extentions to redirect anyway.
When we changed our company name, they changed the domain name of the website without doing a 301 redirect. They did however, set up the server host to redirect customers from the many domain names to the current one. They also already had the multiple domain names that went to the same site, but with a different URL.
The reason that I am trying to do a 301 redirect is because I don't want a duplicate content issue. I want Google to see it as all one website and one domain that was permanently moved.
I also want to obtain the link juice since they are our domains and they do point to the same site. Does that make sense? The domain names are all our company names and they are not the same, but they are all owned by us and go to that site anyway.
2014-08-01 4:49 pm
Hello Joy,
You could probably look at your old site's access logs and see what URLs are still being directly accessed, and then 301 redirect those over to relevant pages on your new site.
If you just wanted to 301 redirect all your old sites to the main landing page of your new site, that should be fine, but you're not going to really get any SEO benefits out of that. As essentially you're telling search engines, this old piece of content that my old site is ranking for about how to tie a tie is now on this new website, but then when the bot gets to the new website there is no information about that search term. So over time if you were ranking for that topic and people are seeing that content no longer exists you'll drop in the search engine rankings for that term.
We would really need a direct example of what it is your're trying to accomplish with your sites to give you a good recommendation. I don't quite understand what it is you're trying to accomplish just by your explanation but if you could give us some real world examples I'm sure we could help you out.
- Jacob
2014-08-01 5:25 pm
As an example: (These are not the real website URL's and if they are, then they weren't used by for the purpose of example only)
We had a company www.movingcompany.com and they were affiliated with a larger company www.vanlines.com, but not owned by that company, but rather an "agent" of that company.
Then www.vanlines.com got purchased and merged with www.biggervanlines.com and we respresented both sides (2 companies) and had two company names www.movingcompany.com (agent of www.vanlines.com) and www.othermovingcompany.com (agent of www.biggervanlines.com)
We also had other devisions of our company like www.recordstorage.com, etc... I don't know who's great idea this was, but this is what I'm working with here lol. And there are about 4 of these.
Then 6 years ago we decided that it was too much and changed our domain to www.movingcompanies.com to represt all of it under one name. I wasn't a part of any of that decision making. I'm just trying to optimize and recover what may have been lost 6 years ago because proper 301 redirects weren't done.
When we changed our domain name, they didn't do any 301 redirects from the old sites to the new site in the .htaccess file. They only redirected through the server host. So the domains are there, but they all have different URLs that take them to the same landing page www.movingcompanies.com (the new site)
Each domain has internal and external site links pointing to and from the domain. What I am trying to do is get www.movingcompanies.com to be reconized by Google as the same domain so that the past links from the old websites are credited to the new website. I just wanted to confirm that 301 redirects were the best possible way to do this or if I should even bother at this point.
2014-08-01 5:40 pm
Hello Joy, thanks for the examples.
Going the 301 redirect route would be how you'd want to transition all of the old domain names to your main new one, and to also let Google and other search engines know about the transition.
However because you're talking about sites that are 6 years old and I'm assuming have different content on the new site, you're not going to really see a SEO benefit for keywords driving traffic to your sites.
For instance in your example if your vanlines.com site is currently ranking on the first page of Google for van moving, and your biggervanlines.com site is ranking for big van moving. If you 301 redirect all requests for these 2 domains to the same front landing page on your movingcompanies.com domain, but you don't have the same content for van moving on that page that allowed your old site to rank well, just setting up a 301 isn't going to make the new site rank any better for that term.
Basically if past links from your old sites aren't relevant to the new site, setting up a 301 redirect will allow people to get to the new site but if the content isn't the same as when it was on the old site it's not going to bring SEO benefits to your new site.
- Jacob
2014-08-01 6:02 pm
Thank you. The content is basically the same. It's a new/old webpage, but they are all moving companies and moving related and because this happened 6 years ago, these domains aren't ranking in Google as webpages. They are only old and there. I'm hoping that the link value will merge because they all essentially link to where the user would want to go. Which is to the moving company that just happened to change domain names awhile back. I appreciate all of your input and help.
2014-08-04 7:11 am
hey Jacob, I am using the followingrewrite rules:
RewriteEngine on
RewriteRule ^courses/chemistry/5-13-organic-chemistry-ii-fall-2003/(.*)$ http://hdl.handle.net/123456789/286 [L,R=301]
RewriteRule ^courses/chemistry/5-12-organic-chemistry-i-spring-2003/(.*)$ http://hdl.handle.net/1721.1/86886 [L,R=301]
but i need to do the deep linking and get the result like :
how can i fetch the 20-320-spring-2006(shortname for URL) and index.htm after the slash(/) dynamically.
Please suggest a way and help me out. Kindly give us a code as a example using my data.
What is the best practice to write a rule in .htaccess file, whether we should write all the redirects in on .htaccess file or we can write it in different .htaccess files for different folders.?
2014-08-04 11:17 am
Hello Abhishek,
I am not quite following your request. Are you saying you want to redirect: http://dspace.mit.edu/bitstream/handle/1721.1/86886/* (meaning anything under the 86886 dierectory) to a specific place?
Kindest Regards,
Scott M
2014-08-08 4:07 am
Can you help on my issue? My website's same content is available via 2 URLs: like http://domainname.com/ and http://XXX.XXX.XXX. XXX opens same content. Similarly it is happening for all internal pages also: http://XXX.XXX.XXX.XXX/internal-content-url/ and http://domainname.com/internal-content-url/ opens same content and google thinks it is duplicate content and drops my site ranks.
I am using dedicated IP on a dedicated server and WordPress CMS
I tried to write redirection URL in .htaccess file but it worked for homepage only not internal pages.
Any advice will be deeply appreciated.
2014-08-08 9:26 am
Hello Anshit,
You can 301 the IP address to the domain name. You may want to try the following code as a template. (Assume an IP address of 126.96.36.199 and a domain name of example.com)
RewriteCond %{HTTP_HOST} ^123\.45\.67\.89$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Kindest Regards,
Scott M
2014-08-08 3:29 pm
Thanks for your reply Scott,
I am using the same code in .htaccess file but it is redirecting only the home page. Not the internal pages.
2014-08-08 4:19 pm
Hello Anshit Gupta,
Check to make sure there are not other .htaccess files within your subfolders. This would cause them to override the rules you are creating in the folder above.
Also ensure there are not other rules within your .htaccess, interfering with this redirect. For example, CMS's typically include a list of rules, and can add more rules from plugins/addons.
If you have any further questions, feel free to post them below.
Thank you,
2014-08-09 3:19 am
Checked it couldn't find any other htaccess file in subdirectories.
Homepage redirects fine but internal pages are still accesible via IP. Don't know whats the reason.
Is there any other alternative besides working on .htacess?
2014-08-11 11:10 am
Hello Anshit,
Give this next piece of code a try. The first, to my knowledge, should have worked as well.
Options +FollowSymLinks
RewriteEngine on
# Redirect all requests for all non-canonical domains to same page in www.example.com
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Kindest Regards,
Scott M
2014-08-14 12:21 pm
Hi eveyone I am having some trouble becaue someone installed a wordpress site in a subdirectory under cpanel because there is a static page create for home so you can see in www.domain.com a page that says enter site and redirects to www.domain.com/wordpress and in .htaccess you can see this code:
Options +FollowSymlinks
DirectoryIndex index.htm index.php
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule ^(.*)$ http://www.domain\.com/$1 [R=permanent,L]
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ http://www.domain.com/wordpress/$1 [R=301,L]
Ok, the things is that I have added an addon domain because I want to have a new site, the domain is www.domain2.info, it is added correctly but when you try to go to www.domain2.info it redirects to www.domain.com/domain2.info/
Thanks in advance for any help.
2014-08-14 12:37 pm
Hello Jorge,
Sorry for the problem that you're having with the domain. This is typically the result of a domain being used as an add-on domain that has either NOT been registered with a domain registrar, or the domain is still undergoing what is called domain propagation.
If you have not registered the domain name, then you can use the Account Management Panel (AMP) to register the domain.
I hope this helps!
Arnel C.
2014-08-14 12:48 pm
Actually the domain is registered and propagated because if you enter it resolves, the problem is that it redirects to the main domain of the account that is why I pasted the .htaccess code of the main domain. The domain is no registered with inmotion but the hosting account is under my inmotionhosting reseller account and the plan has enable addon domains.
2014-08-14 1:12 pm
Hello Jorge,
The reason I mentioned that issue could be a non-registered domain, or a domain undergoing propagation is because we do not know you domain name and it's a common cause to the issue.
The .htaccess file applies to ALL of the folders beneath it unless you provide another .htaccess file. So, if your add-on domain is being affected by the .htaccess file in the primary domain, you need to put an .htaccess file at the root of the add-on domain. This prevents it from following the rules you set in the primary domain's .htaccess file.
Please let us know if you require any further assistance.
Arnel C.
2014-08-18 4:58 pm
My new site uses url names with php queries like
and I need to do a 301 redirect from home.php to home.php?id=home
I have tried
redirect 301 /home.php http://www.mysite.com/home.php?id=home
but this does not work
Can you help with the correct code?
Many thanks
2014-08-18 5:37 pm
Hello Alan,
The problem may have to do with your web server. Try using a re-direct as per the directions above:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/home.php?id=$1 [L,R=301,NC]
If you continue to have problems with the re-direct, make sure to look at the variations above and try these options for your re-direct. Otherwise, please provide us more information on your website, such as the URL, so that we can investigate it further.
Kindest regards,
Arnel C.
2014-08-28 5:16 am
Hi Arnel,
Re my earlier post and your reply.
Thanks for your help. I tried using
RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule ^(.*)$ http://example.com/home.php?id=$1 [L,R=301,NC]
as you suggest but it still does not work! ;(
The web site url is
and I need to redirect old site pages that no longer exist to the new ones that have replaced them
here is what I have tried using
redirect 301 /home.php http://www.standrews-children.org.uk/home.php?id=homeredirect 301 /adoption.php http://www.standrews-children.org.uk/adoption.php?id=adoption_in_scotlandredirect 301 /fostering.php http://www.standrews-children.org.uk/fostering.php?id=foster_care_in_scotlandredirect 301 /adoptionsupport.php http://www.standrews-children.org.uk/adoption_support.php?id=adoption_support_team
You'll get the idea of what I am trying to do.
Any help would be much appreciated.
2014-09-17 11:00 am
The code you provided should work without any issues. Be sure that you do not have anything else in your .htaccess file that may be interfering with the code. Renaming your existing .htaccess file to something else and placing only the redirect code in it will allow for further testing by eliminating other possible issues.
If it still doesn't work, I recommend contacting your hosting provider for more information. As this code works on our servers as well as many other hosts, your host may have something else in there that is preventing the redirect.
2014-08-19 6:46 am
I am currently using a permalink structure with .html extension at the end.
I now want to modify to a permalink without .html extension like
Can you please me with the correct redirection code?
2014-08-19 8:12 am
Hello Anand,
In order to remove extensions in the address bar, you will want to take a look at our article on doing just that.
Kindest Regards,
Scott M
2014-08-21 12:15 pm
I'm not a customer of inmotion, but still hoping for a little insight on the following: If you are moving a blog that currently lives on a blog.website.com subdomain to a new format/design located at www.website.com/blog AND (this is the interesting part) the blog. subdomain is hosted by a separate company from the one which hosts www.website.com, how does one go about implementing the redirects?
My understanding is that you have to "own" the site you're redirecting pages from, as well as the one you're redirecting pages to. So, do you need to have ownership of the blog subdomain transfered from one host to the other? And then have that company upload the .htaccess file for all individual blog post redirects?
Thanks for any help,
2014-08-21 1:14 pm
You do not need to own the destination of a redirect. For example, I can redirect my domain to google.com, or even your blog if I wish. If you do not own the destination site, however, you have no control over how things work on it. That is the caveat. Your .htaccess file can redirect to another server, however any changes on the other server would need to be made on that server by someone with access to it.
I hope that helps a bit.
Kindest Regards,
Scott M
2014-08-22 2:02 pm
Super helpful, and thanks very much for the response!
2014-08-21 1:17 pm
Ok, so i messed up. I was wanting to run a redirect on my 1&1 website. and I had seen a lot of people telling me to alter the .htaccess file in order to do so. I have altered the code to send any mobile browser to an alternate page. The major problem is that the redirect page im using is on the same domain, so I keep getting reloaded on a mobile device. I need to reverse this code and I dont know how. I ran this as a script through my <head> section and when I removed it, it stayed in place because ive altered the server.
Enough of what i think i know:
how do you reverse this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|mobile.+firefox|netfront|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ ce|xda|xiino [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\ wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r\ |s\ )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1\ u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(\ i|ip)|hs\-c|ht(c(\-|\ |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(\ |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(\ |\/)|klon|kpt\ |kwc\-|kyo(c|k)|le(no|xi)|lg(\ g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-|\ |o|v)|zz)|mt(50|p1|v\ )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v\ )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|\ )|webc|whit|wi(g\ |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-) [NC]
RewriteRule ^$ http://www.collinscustomjewelers.com/mobile [R,L]
2014-08-21 2:16 pm
Hello Flapjack117,
If that is the code that is on that domain causing the loop, it appears it needs another rewrite condition that says if it is coming from www.collinscustomjewelers.com/mobile don't try again.
It will look something like:
RewriteCond %{REQUEST_URI} !^/mobile
You can place that right before the rewrite rule so it appears as below:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} (android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|mobile.+firefox|netfront|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ ce|xda|xiino [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\ wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r\ |s\ )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1\ u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(\ i|ip)|hs\-c|ht(c(\-|\ |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(\ |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(\ |\/)|klon|kpt\ |kwc\-|kyo(c|k)|le(no|xi)|lg(\ g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-|\ |o|v)|zz)|mt(50|p1|v\ )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v\ )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|\ )|webc|whit|wi(g\ |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-) [NC]
RewriteCond %{REQUEST_URI} !^/mobile
RewriteRule ^$ http://www.collinscustomjewelers.com/mobile [R,L]
I tested this with my own domain and it worked successfully. Hopefully it will do so for you as well.
Kindest Regards,
Scott M
2014-08-25 8:32 am
Can you tell me why this, placed at the top of my .htaccess file, creates a 500-internal server error?
RewriteEngine onRewriteCond %{HTTP_HOST} ^mydayinuy.com [NC,OR]RewriteCond %{HTTP_HOST} ^www.mydayinuy.com [NC]RewriteRule ^(.*) $ http://mydayinuy.wordpress.com/$1 [L,R=301,NC
2014-08-25 11:34 am
Hello Pat,
I am not quite sure why that code fails. I tested it on my own domain and it also failed. The one below was tested with my own domain and worked correctly. I have replaced my domain name with yours, so it should work for you as well.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydayinuy\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydayinuy\.com$
RewriteRule ^/?$ "http\:\/\/mydayinuy\.wordpress\.com\/" [R=301,L]
Kindest Regards,
Scott M
2014-08-28 10:30 am
I have a question, please anyone out there help me!!
if a user email address like "email@example.com" when form is submitted, it should go to their specific domain name i.e, www.example.com,
same should go for user like "firstname.lastname@example.com", this should be automatically go to the www.gmail.com when submit the form is submitted.
simply that have to redirect to the domain name after the @ symbol?
I want my redirect to be to the specific domain names after their @symbols
Thanks in advance
2014-08-28 10:36 am
To clarify, it sounds like you want to redirect users to their email provider after they submit a contact form? If so, this can be done with custom PHP form processing through custom code on your site, but cannot be done in a simple manner.
2014-08-28 4:33 pm
Can you please direct me to any custom php code to achieve this project.
I need a custom to redirect users to their email provider after they submit a contact form?
2014-08-29 9:29 am
Hell Remax,
Custom code means that it does not exist and would have to be written from scratch, so there is no code for us to point you to.
Kindest Regards,
Scott M
2014-08-28 3:59 pm
yes, exactly that is what i want to achieve, can you please give me any php script or code to achieve this. I want to redirect users to their email provider after they submit a contact form? can you please refer me to a php script or code i can use to achieve this.
Thank you in advance
2014-08-28 4:18 pm
Unfortunately, this is not something we would be able to write for you and I am unaware of any solutions that exist for this. Basically, you will need to parse the user input with PHP and redirect the user after form submission based on the data provided. If you are not a developer, the best solution would be to hire a developer to code this for you.
I would also like to add that while it is possible, it is not ideal for user experience and can cause a large number of users to become confused and thus cease activity on your site.
2014-08-28 4:37 pm
Thanks, i will appreciate if you can assist me. Just let give me a clue and where to find one good custom php code to make use of
2014-08-29 9:30 am
Hello Remax,
Custom code means that there is not an existing script to do what you ask (that we know of.) You will either need to code it yourself or hire someone to do that as a small project.
Kindest Regards,
Scott M
2014-09-01 6:38 am
in my site wordpress is installed in subfolder http://abcd.chaitanya.com/blog to http://abcd.com/blog using htaccess with www infront of the site address
2014-09-02 1:53 pm
Your comment is a bit unclear. Could you clarify?
2014-09-03 8:40 am
Hi Jeffma,
Sorry i forget to mention some notes in my previous comment.Actually i installed wordpress in subfolder .
My site is a subdomain.
Now what my question is how to redirect the site when the user enter the url like
http://abcd.chaitanya.com/blog to http://abcd.com/blog
Because When i make advance search in google it is giving duplicate links.
How can i redirect this using htaccess
2014-09-03 11:55 am
I am trying to re direct just the home page and not the robots.txt file
2014-09-03 1:09 pm
Hello Andy,
The article itself assists in redirecting pages and does not mention robots.txt. Is there something specific you have a question about?
Kindest Regards,
Scott M
2014-09-03 1:15 pm
Hello Chaitanya,
You would use the rules for redirecting from old domain to new domain.
Kindest Regards,
Scott M
2014-09-08 11:39 pm
Hi Bro, I want redirect my blog:
- olddomain.com to newdomain.com
- olddomain.com/oldpage1 to newdomain.com/newpage1
- olddomain.com/oldpage2 to newdomain.com/newpage2
Thank you in advance
2014-09-09 8:00 am
Hello Lee,
The rules for redirecting the old domain to the new are above in the article.
The second requests about redirecting the old domain/page to a newdomain/page will be a combination of the old domain to new domain and the redirect from one file to another.
Kindest Regards,
Scott M
2014-11-21 5:16 pm
Hi, very useful page - but I'm a bit stuck on this too. How would that 'combination' look exactly? Does the domain redirect go first, then each individual page? I'm just wondering, won't the domain redirect just redirect all old pages to the new home page, overiding the individual page redirects?
Many thanks :)
2014-11-21 6:02 pm
Hello Jon,
What type of redirection are you trying to do exactly? Can you provide us an example of what you are trying to redirect from and to?
Kindest Regards,
TJ Edens
2014-11-28 1:45 pm
Hi, I'm going to need to 301 redirect some specific pages from my old site divineweddingcakes.co.uk to specific pages on my new site at divineweddingcakes.uk (note different domain), but also to redirect all other old pages to the new home page.
Eg. divineweddingcakes.co.uk/oldpage1 redirects to divineweddingcakes.uk/newpage1
but also divineweddingcakes.co.uk/anyotheroldpages redirects to divineweddingcakes.uk
Thank you in anticipation,
2014-11-28 3:50 pm
Hello Jon,
You didn't really ask a question, but I'm going to assume that you're looking for direction on creating re-directs for you website. We do not provide the code for you, but we do try to provide a tutorial that will help you in your task. Check out Setting up a Re-direct in cPanel.
I hope this helps to answer your question, please let us know if you require any further assistance.
Arnel C.
2014-09-10 5:37 am
Hi buddies, nice piece of info stuff. I can't find a solution for my trouble and it's not stated in your article.
I have a domain www.example.net. I would like to move all website content of that domain to a subdirectory in another domain, say www.whatever.com/example
Obviously this should be "transparent" for users, so they shouldn't realize of this change, nor should affect to web browsing or web opeations.
Can be this done via .htaccess?
2014-09-10 8:04 am
Hello Ralph,
The method should mirror the redirect from old domain to new domain with one change. The new domain code portion should also include the subfolder you are using as the root for the content.
Kindest Regards,
Scott M
2014-09-10 10:50 am
Hi Guys,
Need some help.
Apparently there are some old links to us out on the internet for some of our old domains.
The new domain is www.bvtlive.com
None of the below exists at all. and is redirected to bvtlive.com
I have tried redirection www.brandywinevalleytalent.com to www.bvtlive.com which does work using the following.
## redirect brandywinevalleytalent.com
RewriteCond %{HTTP_HOST} ^brandywinevalleytalent.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.brandywinevalleytalent.com [NC]
RewriteRule ^(.*)$ http://www.bvtlive.com/$1 [L,R=301,NC]
## redirect bvtbands.com
RewriteCond %{HTTP_HOST} ^bvtbands.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.bvtbands.com [NC]
RewriteRule ^(.*)$ http://www.bvtlive.com/$1 [L,R=301,NC]
BUT when the url is as below with additionalinfo on the end it redirects...
FROM: http://www.brandywinevalleytalent.com/jellyroll/blog.asp
TO: http://www.bvtlive.com/jellyroll/blog.asp
This dosen't really help because the asp no longer exists since this is a joomla site.
I would love if i could get it to go...
FROM: http://www.brandywinevalleytalent.com/jellyroll/blog.asp
TO: http://www.bvtlive.com/
Any help in the htaccess rhelm would be appreciated.
John H
2014-09-10 12:48 pm
Hello John,
Sorry for the re-directs. I checked both of those domains and they still do exist on the internet. You would need to contact the domain registrars managing those domains and then either shut them down or change the DNS to point to our hosting service. Your re-directs for those domains will not work unless the DNS is being read from our servers. Otherwise, you would have to create those redirects where ever those domains are being hosted.
I hope this helps to clarify the matter. If you still require assistance, please let us know.
Arnel C.
2014-09-12 11:05 am
Hi friend
i would like to redirect www.example.net to www.example.com
i have done this through 301 redirect
but unfortunately robots.txt also redirect to www.example.com/robots.text and shows 404 error
i dont want to redirect www.example.net/robots.txt to redirect to .com however all other page i need to redirect to .com
i need to keep robots.txt on .net so that google bot completely deindex all pages
i need solution to handle this sitution
thanks in advance
2014-09-12 12:02 pm
Hello Sohel,
You may want to add an exception to your rules just under the http host condition, right before the rule. Below is a condition that says to ignore the redirect for /robots.txt.
RewriteCond %{REQUEST_URI} !^/robots\.txt$
Also, by 301 redirecting the .net to the .com, Google will drop the index of the .net anyway. Also, you can dictate this behavior specifically in Google's webmaster tools.
Kindest Regards,
Scott M
2014-09-12 3:07 pm
Hello scott
thanks a lot for direction
by reading all post i expect answer from you and u have did it
i was puzzled whole day to solve this
Now second issue is that we have two website
(1) www.example.com in this web site when we open any url of web site with HTTPS then browser ask for security and then open the same html page of HTTP. so my issue is google consider such variation as domain variation and if yes is google penalised for in this case for duplicate content and if yes then how to resolve such situation through .htaccess redirect (301) hosting Net firm
(2) www.example.net on this web site when we open any url with https then it return to home page of hosting provider (cPanel Home Page) altough we have removed the home page of hoster from server
so my question why such difference on two website
is https and http difference in domain effect SEO
it is necessary to Redirect HTTPs to http through 301 and if yes please mention code
lastly why such difference arise
i came to know about this issue from siteliner.com seo toolsagain thanks in advance
2014-09-12 4:49 pm
Hello SOHEL,
Thank you for your question. It is difficult to say what will help your SEO, since only Google knows the algorithm, and they make changes to it regularly.
I don't think google will see an https site being accessed via http as duplicate content. But a recent post in Google's Official Webmaster tools blog states "we're starting to use HTTPS as a ranking signal. For now it's only a very lightweight signal — affecting fewer than 1% of global queries, and carrying less weight than other signals such as high-quality content — while we give webmasters time to switch to HTTPS. But over time, we may decide to strengthen it, because we'd like to encourage all website owners to switch from HTTP to HTTPS to keep everyone safe on the web."
If your site is redirecting to another URL, you may have to update the URL in the software. For example in WordPress, Joomla, etc. have to update the URL in the software settings.
If you have any further questions, feel free to post them below.
Thank you,
2014-09-17 8:37 am
Dear friends,
we bought an expired domain that apparently has a lot of backlinks to main domain but also in several different subdomains of the main domain name. As we rebuild from scratch and on a different style,links etc this domain, we want to be able with a central rewrite command to keep all the link juice on Google from any other subdomains or indexed pages of the old domain driving to the new domain automatically.
Is this command the correct to use or we have to use something different?
RewriteEngine on
redirectMatch 301 ^(.*)$ http://www.domain.com$1
redirectMatch permanent ^(.*)$ http://www.domain.com$1
Any help would be really appreciated.
2014-09-17 11:28 am
Your code is somewhat correct. It appears that you are checking for a pattern to redirect, but not actually defining where to redirect to. I recommend looking at the code examples that are within this article for more complete code.
2014-09-17 2:16 pm
Jeff thanks.
I try to redirect all the previous subdomains indexed on Google to my homepage of the newly rebuilt site.
In other words to simplify, everything that is already indexed on these subdomains, has a huge linkjuice from before on the subdomains. I try to show Google, that the new relevant content from all these subdomains.domain.com previously indexed(existed on Google) for this major domain.com which we bought, can be now redirected at www.domain.com.
I hope there should be a redirect code that with a bit regex can redirect not?
2014-09-17 2:50 pm
If you're trying to redirect various subdomains to other locations, chances are you won't be able to do it automatically to particular locations. You can, however, set a particular subdomain to redirect to the main domain. To do so, you would need to create each of those subdomains, and place redirects from those subdomains to your target location.
2014-09-17 5:30 pm
So in fact I create the subdomains, I 301 them via cpanel to the main site and all the rest indexed I find I use the:
RewriteEngine on
redirectMatch 301 ^(.*)$ http://www.domain.com$1
redirectMatch permanent ^(.*)$ http://www.domain.com$1
Is this correct, or I am missing something. Jeff in fact I try to redirect any indexed url to my main new site. These indexed links are a lot and I try to find a general rule that I redirect everything to the main site so that I don't lose the juice as the old site (old owner) was very relevant to what we build.
2014-09-17 5:42 pm
If you place those lines within the .htaccess file of the root directory for each of the subdomains, they will redirect to the appropriate location that you have defined. If you're not seeing the change, try clearing your browser cache as you may have some cached data there.
2014-09-17 5:31 pm
Greetings. I am hoping I can get some advice on how to most efficiently accomplish the following, any help would be appreciated:
1. We are rebuilding a new site, in Drupal, on a test domain.
2. We will transfer it to the URL that the current site is located at upon completion.
3. During the process the URL structure will change.
4. We would like to find the easiest way to redirect or eliminate the possibility of having tons of 404s on our site. The site has 1,000s of pages so changing URL structures by hand is not possible.
Thanks in advance.
2014-09-17 5:39 pm
Movie a Druapl site back and forth between testing and production environments is quite simple. The following article will help you in doing so:
Setting up a Druapl test site
2014-09-19 10:03 am
Thanks, Jeff.
We have already created the site on a seperate domain, not a sub-domain.
The concern is that when we move the site from the test domain (where the site is being built) to the current domain, where the old site is currently located, that we will end up with tons of 404s due to the URLs of the original site no longer being used.
1. Do you think this is an issue in terms of SEO?
2. Is there an easy or bulk way to recreate the URLs of the test site so they match the URLs of the current site?
3. If no to number 3, would it be best to redirect?
Thx in advance
2014-09-19 10:34 am
Hello Jason,
If you do not have the same structure in the new site, you may have some work ahead of you. You may not need to create a redirect for each of the old pages to go to the new pages, but you may need to create redirects from other categories, subfolders, etc to point to the new ones.
For example: oldsite.com/old-category/page1 to newsite.com/new-category/page1
For that you would need to set up a 301 for the domain to redirect anything from oldsite.com/old-category to newsite.com/new-category. If you had 100 pages under that old-category, then you have successfully set the redirect for 100 pages. If you have thousands of pages, this may still mean quite a few lines of code to get all the site redirected properly.
Kindest Regards,
Scott M
2014-09-17 11:22 pm
I have about 150+ websites and I want to create one .htaccess file for all. in your code i have to add example.com (website name) in it.
Is there any code I can use whatever domain it is, it should redirect from www to non www ?
2014-09-18 10:40 am
Hello Abid,
The code you are looking for is as follows:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
We have tested it on our servers with multiple domains and it works fine. Note that it only works for all domains on a single cPanel, so you will need to place it at the highers folder point in each cPanel so it works for all domains.
Kindest Regards,
Scott M
2014-09-18 4:16 am
Plz help me to redirect my website from http://empirepropertiesdubai.com/ to http://www.empirepropertiesdubai.com/
2014-09-18 8:40 am
Hello Manoj,
The instructions for what you are asking are above under the "Forcing the www version of domain to be used" section. Follow that and your site will always redirect to the www version.
Kindest Regards,
Scott M
2014-09-20 1:25 am
Thanks for putting this info up...had looked at several other sites info and nothing was working. Your example was spot on and problem was solved.
2014-09-20 7:48 pm
I have gone through your tutorial. It has given me enough information to redirect the url. Based on your tutorial i have written for my code. But its not working
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ FresherOffcampuApply.php?var=$1 [R=301, L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ FresherOffcampuApply.php?var=$1 [R=301, L]
Please help me as this is hampering my work as lot.
2014-09-22 8:52 am
Hello Padmaraju,
What is it you are trying to do exactly?
Kindest Regards,
Scott M
2014-09-22 7:10 pm
My problem is that i have a url like this-
I want to show like this in the url
For this i have written the .htaccess code as
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ FresherOffcampuApply.php?var=$1 [R=301, L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ FresherOffcampuApply.php?var=$1 [R=301, L]
But this doesn't work. Please help me on this.
2014-09-22 7:20 pm
The following rewrite rule should work in redirecting as you would like it to:
RewriteEngine On
2014-09-23 11:03 am
I have tried in the same way but am getting the below error-
[error] [client 127.0.0.1] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
2014-09-22 4:45 am
I think this is a brilliant article, which clearly demonstrates the results of the given code.
No improvements should be made, as it is clear, concise and relevant.
2014-09-22 2:06 pm
here my site at present in demo2.com/demo and i want to redirect this domain into demo.net/demo and i have changes in .htacces like this
RewriteEngine on
RewriteCond %{HTTP_HOST} !^demo2.com/demo
RewriteRule ^(.*)$ demo2.com/demo [R=permanent,L]
RewriteCond %{REQUEST_URI} !^/$
RewriteRule ^(.*)$ demo.net/demo [R=301,L]
and refresh my browser then it's says "This webpage has a redirect loop"
any solution on this.
2014-09-22 4:06 pm
Hello Abhishek,
Thanks for providing some detail on the problem you're having. It has to do with how you wrote the rewrite rules. Here's how it should work. The comments below explain each line:
RewriteEngine On
#checking for the domain
RewriteCond %{HTTP_HOST} ^demo2\.com$ [NC]
#checking to make sure that the URL is "/demo"
RewriteCond %{REQUEST_URI} ^/demo$ [NC]
#with those two conditions met, the rewrite rule can now re-direct correctly
RewriteRule ^(.*)$ http://demo.net/demo [R=permanent,NC,L]
I hope that helps to explain the issue! Please let us know if you have any further questions.
Kindest regards,
Arnel C.
2014-09-29 6:20 am
Very nice article.....
2014-09-30 9:35 am
I have a website built on Joomla, Now I want to convert it to .php version, How to redirect the old URL to New URL.
For Example
www.mydoamin.com/aboutus to www.mydoamin.com/aboutus.php
How achive this?
Total I have got 40 to 50 URL's. Do I need to create each and every folder like aboutus folder, in that index.php, in that 301 rdirection code to the new URL(aboutus.php) or How to achive this.
Plz. help me and do the needful.
Thankyou in advance.
2014-09-30 1:15 pm
Hello Naveen,
Thanks for your question. However, it doesn't make too much sense as a website built in Joomla is already using PHP. So, when you say "convert to a PHP version" we're not quite clear about what you are trying to do. You can use a the rewrite options as instructed above to re-direct people to your new URLs. We're not sure what you're trying to do in the re-creation of the site in PHP. If you are building a new website, then the URLs should be different and the re-direct are only being used to preserve search engine rankings from the older site.
If you have any further questions, please let us know. If you have any further specific questions, please let us know.
2014-09-30 4:51 pm
I'm trying to redirect some old pages on my WordPress site. I am redirecting:
Redirect 301 /work /our-work/
Redirect 301 /work/ /our-work/
Redirect 301 /work/project1 /our-work/
I have renamed the folder and also expired a project page that I want to redirect to the parent folder. The folder redirect works, but the expired URL redirects to /our-work/project1, which is not what I want as the page no longer exists. I am new to redirecting - what am I doing wrong?
Thanks in advance.
2014-09-30 5:18 pm
Hello Lee,
Sorry to hear about your redirect problem. You did not give us enough detail on the problem. Can you provide the actual URL, and the code used to make the redirects? The information you're providing is not complete enough to assess the issue. Provide us a little more information and we would be happy to help!
Arnel C.
2014-10-01 3:45 am
Yes, sorry more details would have helped. The domain is http://designbycream.com. The HTAccess file has the standard wordpress rule applied and I am trying to redirect some child pages back to the parent folder as they have expired. I am also trying to redirect the old folder name to the new one and I think this is where I am having the issues.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Redirect 301 /work http://designbycream.com/our-work/
Redirect 301 /work/ http://designbycream.com/our-work/
Redirect 301 /work/long-mynd http://designbycream.com/our-work/
2014-10-01 9:42 am
This may be causing issues because the WordPress rewrites are being called before the redirects which can handle the files a bit differently. Instead, try placing the redirects before the rewrites provided by WordPress.
2014-10-01 5:44 am
Hi, thanks for your early reply,
Sorry, if I had not provided sufficient info. Here is the brief description about my issue.
Right now we have http://www.example.com/aboutus in joomla platform. For the same page the URL is going to change in new website. The new URL would be http://www.example.com/aboutus.php.
other example would be http://www.example.com/ongoing-projects/aboutus is a joomla page, now the new php page would be like http://www.example.com/ongoing-projects/aboutus.php . Which is the appropreate method to do the SEO friendly 301 redirection method. I have got 100+ URL's to redirect.
2014-10-02 3:19 pm
If All of the files have the exact same parrtn and simply need to add .php to the end of them, the following .htaccess rule may be used:
RewriteEngine On
2014-10-03 4:56 am
Solved the issue thank you. Best advice found on web (google) how to use 301 on apache server.
Tried several versions on www.africasiaeuro.com - africasiaeuro.com , only yours worked.
Great job, well explained
2014-10-04 1:30 pm
I once set up a 301 redirect to direct mastechpowersupply.com to www.mastechpowersupply.com, and deleted the redirect in the htaccess file afterwards. however, the redirect seems still in place. is this normal and how can I get rid of the redirect?
2014-10-06 10:41 am
Hello Sean,
I visited your site using the non-www version and was not redirected. It seems to now be working correctly. If you are still having that experience, you may want to test another browser or clear the cache of the affected browsers. Once the command is removed, it should no longer redirect.
Kindest Regards,
Scott M
2014-10-04 3:47 pm
My WAMP Keeps redirecting to live site url, e.g. when I type localhost/my-site, the browser redirects to http://my-site instead od http://localhost/my-site....please what can I do to repair this.
Thank you
2014-10-06 11:47 am
Hello Damilola,
It can depend on what your site is doing. It may have code that redirects based on configuration information in either files or the database. Check your .htaccess file to ensure the proper code is there and no other code is present that can interfere.
Kindest Regards,
Scott M
2014-10-06 11:53 am
Hello Damilola,
Sorry to hear you're having problems with WAMP. Since WAMP is a product that runs on a local computer (not on a server), we do not generally support it. Based on what you are saying though, it appears that you either need to modify your HOSTS file or review your installation instructions for WAMP.
Arnel C.
2014-10-07 5:46 am
Hello Scott, you legend. Any change of a quick bit of help for me? I have a url:
that i want to redirect to
...any chance you could tell me what to put into my .htaccess file!?
2014-10-07 8:03 am
The specific lines you would place in your .htaccess file would be:
Redirect 301 /tag/website-design-limerick/ /tag/web-design-limerick/
2014-10-07 11:03 am
That's fantastic thanks. And it worked a charm. Brilliant!
2014-10-07 1:35 pm
No need to improve. It was concise, clear and helpful.
2014-10-09 7:47 pm
Please what can i do i have redirected my Domain A (old domain.info) to my Domain B ( new domain.com) but all search engine linking to my Domain A is not directing to the link on Domain B its bringign 404 errors! what can i do do get out of this.?
2014-10-09 8:22 pm
Hello Ogunfeitimi,
Sorry to hear that you're having problems with the search results. The problem that you're having should be able to be resolved with a wildcard re-direct. This means that ANY path that used the old domain should be re-directing with the new domain. This can be done in cPanel with the Redirect option, or you can make the changes directly in .htaccess. The 301 re-direct information in the article on this page gives you the information for making these changes. Your re-direct should not be limited to a single page if you have multiple website pages that are affected by the domain name change.
I hope this helps to provide the information you need to correct the issue. Let us know if you have any further questions.
Arnel C.
2014-10-10 4:15 am
Hello thanks for the response, please how can i direct my redirect to so many pages as you discussed ? its a blog so i have so many search engine indexxes of my post!
2014-10-10 9:31 am
Hello Ogunfeitimi,
You should be able to get the desired behavior by following the instructions in the Redirect an old domain to a new domain section above. If not, please give a sample of the code you are using so we can see what may be wrong.
Kindest Regards,
Scott M
2014-10-14 5:24 am
i am facing problem to redirection of the all post url to new one url with category name will come before post name. i will get all post name and category name .
just want to how to place it into htaccess file for redirection
want to write script into htaccess for redirection on click of button in plugin
2014-10-14 8:03 am
Hello Vivek,
If you are working with a CMS, for example WordPress, it is best work within the dashboard to set up the PermaLinks or Search Engine Friendlys (SEF) URLs. Working within the .htaccess file overwriting what the CMS is expecting can break your site altogether.
Kindest Regards,
Scott M
2014-10-14 7:01 pm
Last time the site is running in non-https so all links are already cache and index for that version and we recently purchase a ssl cert to secure https version of the site. Is it recommended that all pages should be in https or only those login and register page or my account page in OpenCart.
How about redirecting from http to https version it seems that the old links are still in http version for example.
it will open in the url ask https://www.domain.com/index.php?_route_=about-us
is it okay to leave this or does it need config to work this on the expected url which is
2014-10-14 7:05 pm
It is perfectly fine to use HTTPS on all pages and actually now recommended by Google. As far as the redirects, once OpenCart is configured for HTTPS, it should redirect automatically.
2014-10-18 12:18 pm
I am using this RedirectMatch 301 (.*)\.html$ http://www.mydomain.com$1/ to redirect all of my pages from .html to just a directory.
It seems to be working except all the links to the homepage of my site are being redirected to /index and I have receiving a 404 error.
I am using Joomla with sh404sef.
Any help is appreciated.
2014-10-20 12:02 pm
Hello Chris,
Sorry to hear that you're having problems with the re-direct. Unfortunately, you have not given us enough information in order to determine why the direct is not working. I know that we can make re-directs directly in Joomla. Make sure that you have now re-directs in Joomla directly affecting your site.
If that is not the case, please provide us your domain URL. If you are a customer we would be able to look at the re-direct code in the .htaccess and see how it's affecting your site. If you are not a customer, then still do provide the site URL, and copy of your .htaccess file to review the issue.
Arnel C.
2014-10-21 10:54 am
I can get the redirect to work properly except for my homepage. When I add the redirect in, my domain www.classic-tv.com forwards to www.classic-tv.com/index.
Other than that it works perfectly!
I am not a customer.
# BLOCK BAD BOTS AND USER AGENTSErrorDocument 403 "Forbidden"ErrorDocument 416 "Requested Range Not Satisfiable"RewriteEngine OnRewriteCond %{HTTP_USER_AGENT} Mozilla\/5\.0\ \(\) [OR]RewriteCond %{HTTP_USER_AGENT} ^Mozilla\/4\.0$ [OR]RewriteCond %{HTTP_USER_AGENT} Mozilla\/4\.0\ \(compatible;\) [OR]RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]RewriteCond %{HTTP_USER_AGENT} ^Mozilla$ [OR]RewriteCond %{HTTP_USER_AGENT} \.NET\ CLR [OR]RewriteCond %{HTTP_USER_AGENT} pid$ [OR]RewriteCond %{HTTP_USER_AGENT} Tweetmemebot/|TweetedTimes|TwitterFeed|Twitterbot/|Flipboard|SocialBot|Digg|TwitterCrawler [NC,OR]RewriteCond %{HTTP_USER_AGENT} PHP/|Java|Incutio|Moreover|MetaURI|kraken/|Slurp|Livelapbot/|ShowyouBot|EasouSpider|ADmantX|WBSearchBot|LinkpadBot|Blekkobot|Wotbox|ZumBot|Blekkobot|CCBot|360spider|meanpath [NC,OR]RewriteCond %{HTTP_USER_AGENT} proximic|Photon/|Jakarta|HttpClient|python|ruby|jack|NING|curl|DotBot|bitlybot|crawler4j|Marfeel-crawler|WinHttpRequest|HubSpot|DBot|ASProxy|XoviBot|SpiderLing|URLAppendBot [NC,OR]RewriteCond %{HTTP_USER_AGENT} CCBot|AlexaBot|Owlin|Spinn3r|Genieo|Riddler|SeznamBot|360SE|LBBROWSER|Infegy/|Sogou|bixocrawler|uMBot|Grapeshot|NextGenSearchBot|GroupHigh|aria2|HttpTool|whisper [NC,OR]RewriteCond %{HTTP_USER_AGENT} RSSList|Synapse|gsa-crawler|CrawlerProcess|InAGist|CRAZYWEBCRAWLER|FatBot|ShopWiki|coccoc|Bork|YaBrowser|AddThis|Arachnophilia|woobot|Wayback|trendictionbot|ELNSB50 [NC,OR]RewriteCond %{HTTP_USER_AGENT} junglee|RediffNewsBot|Alertmix|Exabot|FunWebProducts|PaperLiBot|linkdexbot|Twurly|Embedly|feedjira|Kimengi|Junkie|newspaper|Percolate|newsme|feedzirra|a6corp|Twingly|LongURL [NC,OR]RewriteCond %{HTTP_USER_AGENT} as_qdr|netEstate|tools\.ua\.random|archive\.org|Edition\ Campaign|Anturis|rogerbot|MojeekBot|meanpathbot|JS-Kit|Dispatch|grokkit|OpenHoseBot|Twikle|Icarus6j [NC,OR]RewriteCond %{HTTP_USER_AGENT} Sztaki-kereso|Sysomos|spbot|magpie|maxpoint|PagesInventory|Abonti|TNX|YahooCacheSystem|knelson|voltron|acapbot [NC]RewriteRule .* - [R=416]
# BLOCK ABUSIVE USER AGENTSRewriteEngine onRewriteCond %{HTTP_USER_AGENT} Mozilla\/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.1\) [NC,OR]RewriteCond %{HTTP_USER_AGENT} Mozilla\/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.1\ SV1\) [NC,OR]RewriteCond %{HTTP_USER_AGENT} Mozilla\/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.1;\ SV1 [NC,OR]RewriteCond %{HTTP_USER_AGENT} Mozilla\/4\.0\ \(compatible;\ MSIE\ 5\.0;\ Windows\ 95\) [NC]RewriteRule .* - [R=416]
RewriteEngine OnRewriteCond %{REQUEST_URI} ^/joomla3/ [OR]RewriteCond %{REQUEST_URI} ^/images/RewriteCond %{REQUEST_URI} \.(png|jpg|jpeg|ico|bmp|gif)$ [NC]RewriteRule .* - [L]
# KNOWN FORUM SPAM SOURCE IP BLOCKSdeny from 27.deny from 37.221.deny from 50.19.deny from 50.28.deny from 54.deny from 62.210.deny from 65.deny from 64.95.deny from 77.95.deny from 77.109deny from 77.247.deny from 85.17.deny from 94.23.deny from 107.22.deny from 120.43.deny from 140.237.deny from 149.210.135.deny from 155.94.deny from 183.252.deny from 188.138.deny from 188.165.deny from 192.3.deny from 192.95.deny from 192.99.deny from 192.161.deny from 192.171.deny from 192.199.deny from 192.227.deny from 192.240.deny from 192.255.deny from 193.201.deny from 195.2.deny from 195.211.deny from 198.deny from 202.46.deny from 204.12.deny from 208.66.deny from 216.107.156.
AddType audio/mpeg mp3AddType audio/mp4 m4aAddType audio/ogg ogaAddType audio/webm webmaAddType audio/wav wavAddType video/mp4 mp4AddType video/mp4 m4vAddType video/ogg ogvAddType video/webm webm
#preserve bandwidth for PHP enabled servers <ifmodule mod_php4.c> php_value zlib.output_compression 16386 </ifmodule>
#If available, set the expires to 'far future'<IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 1 month" ExpiresByType application/pdf "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 week" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/ico "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/x-icon "access plus 1 month" ExpiresByType text/css "access plus 1 month" ExpiresByType video/x-flv "access plus 1 month"</IfModule>
#Turn off ETagsFileETag none
## Can be commented out if causes errors, see notes above.Options +FollowSymLinks
## mod_rewrite in use
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL# is not directly related to physical file paths.# Update Your Joomla! Directory (just / for root)
# RewriteBase /
########## Begin - Joomla! core SEF Section#RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_URI} !^/index.phpRewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]RewriteRule (.*) index.phpRewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
########### End - Joomla! core SEF Section
RewriteEngine On
# Uncomment following line if your webserver's URL# is not directly related to physical file paths.# Update Your Joomla! Directory (just / for root)
RewriteBase /
########## Begin - Rewrite rules to block out some common exploits## If you experience problems on your site block out the operations listed below## This attempts to block the most common type of exploit `attempts` to Joomla!## Block out any script trying to set a mosConfig value through the URLRewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]# Block out any script trying to base64_encode crap to send via URLRewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]# Block out any script that includes a <script> tag in URLRewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]# Block out any script trying to set a PHP GLOBALS variable via URLRewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]# Block out any script trying to modify a _REQUEST variable via URLRewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})# Send all blocked request to homepage with 403 Forbidden error!RewriteRule ^(.*)$ index.php [F,L]########### End - Rewrite rules to block out some common exploits
2014-10-21 11:10 am
This is because Joomla uses rewrites for their search engine friendly URLs. To remove the .html suffix from your URLs, you may go to your search engine friendly URLs section and turn Add Suffix to URLs to off.
If you prefer to do it directly within your .htaccess file instead of doing so within your Joomla admin, you can add the following to the bottom of your .htaccess file instead:
RewriteEngine On
2014-10-21 3:52 pm
Yes, but I want to truely redirect my old .html page to one with out the .html.
For years my site's pages ended in .html and I've since decided to change that. Now all of my links in Google, etc do not forward to the new page without the .html
The redirect you gave works fine except my hompage redirects to /index instead of just staying on the .com.
2014-10-21 4:07 pm
I went to your site to try to replicate the issue and currently I was unable to see a problem. I also attempted to add .html to the end of the URLs in which I do see they are redirecting correctly.
2014-10-21 4:16 pm
That's because I do not have the redirect added right now because it redirects my homepage to /index.
Look at this page http://www.classic-tv.com/ratings/1950-1951-tv-show-ratings.html
you'll get a 404.
The URL is really http://www.classic-tv.com/ratings/1950-1951-tv-show-ratings
Some pages I've manually added through my Joomla SEF program to forward correctly.
2014-10-21 4:18 pm
Unfortunately, due to the way Joomla works, there isn't a way to avoid the issue with it redirecting to /index on the home page with an overall redirect. Your best solution would be to create each of the redirects individually for the pages that you are getting 404 errors on.
2014-10-21 8:51 pm
Hi, I just launched a WordPress redesign of an .htm website that started as www.example.com and is now example.com. The site owner changed the names of some pages, some urls were misspelled and I fixed them, and there were a few other changes to the site structure, along with many pages that didn't change except for the .htm becoming a trailing slash. I started with individual redirects like this:
Redirect 301 http:/www.example.com/page.htm http://example.com/corrected-page/
But it didn't work, so I tried this:
Redirect 301 .page.htm http://example.com/corrected-page/
Still didn't work, and my client is on the way to a conventino, so for expediency's sake, I did this:
Redirect 301 http://www.example.com http://example.com
This of course redirects the home page, getting people where they need to go for the newly presented site, but direct requests and the old site links in search results still land on the old pages. Since this site has been online since 1985 and most pages are ranking around a 4 and appear in serp well for keywords, we do want to transfer the link juice to the new site, but I'm a bit stumped as to why my first redirect attempts didn't work. can you dial me in on how to resolve this?
2014-10-21 10:19 pm
As you are using WordPress, there is a WordPress plugin called Redirection which will allow you to easily add redirects as well as other things like monitor your 404 pages.
2014-10-22 11:30 am
LOL! I guess patience was the best solution on this one. I had just installed the Redirection plugin and had entered one redirect when I got detoured back over to Google, did a fresh search for my client's site, clicked one of the subpages and it took me straight to the new version! Started clicking on others with the same wonderful results! I guess since his site has been online for 21 years, the search engine just took a little longer to "believe" it was being redirected than they ordinarily do. My past experience with redirects in htaccess is that they pretty much take effect immediately and this is the first time I've had it take nearly 24 hours to kick in. Always good to know that some things do take time. Thanks so much for your suggestion, though, I'll keep that in mind for future projects.
2014-10-22 4:29 pm
Hey guys, hoping you could help with an http to https redirect question.
I'm trying to force https for all pages on an ecommerce site. Forcing this is not the issue, but I would like to do so and have the redirects be 301's instead of 302's. Also on of the biggest issues is the main domain https://www.website.com/ is redirecting to itself via a 302.
This prevents me from using any crawler type tools such as Screaming Frog, Xenu, etc. for any site diagnosis.
Here is the original code: we have played with it a bit but figured I would just give the original.
RewriteEngine On
# masks .php extension
RewriteBase /
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# denies trace/tracks
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
# Forces SE into HTTPS
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.website.com/$1 [R,L]
# no directory listings on directories without an index
Options -Indexes
# deny access to sys config files
<Files ~ "\.htpasswd$|\.inc$">
order allow,deny
deny from all
I tried adding the R=301 but that didn't fix the main url issue.
Thanks in advance!
2014-10-22 5:51 pm
Hello Jason,
Sorry for the problem. You said that adding the 301 designation did not fix the problem, but you didn't say if it was causing an error. And literally, you're not pointing to a different domain, so the re-direction definition is correct. That's not something you can change for the sake of the site diagnosis tool. You would need to change it to a different domain for the 301 to be appropriate. Everything else looks correct, so we're unsure if there's anything we can change in the re-direct code at this point.
Arnel C.
2014-10-22 5:57 pm
Thanks for the replay Arn,
I didn't get an error although, the main domain was still showing a 302 and redirecting upon itself in an endless loop it seemed. I tried replacing the redirect portion of code above:
# Forces SE into HTTPS
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.website.com/$1 [R,L]
With this:
# Forces SE into HTTPS
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
And that is how it is currently. I didn't know if we could disallow so to speak the https://www.website.com/ from redirecting to itself or not - or if that would fix anything. The above version forces 301's other than for the https://www.website.com/ which remains a 302 upon itself.
Appreciate your time :)
2014-10-22 6:20 pm
Hello Jason,
No problem, and sorry I'm not able to give you a good work-around for this issue. Everyone I've asked about this has said that since the domain is redirecting to itself - regardless of the https - the redirect is classified (correctly) as a 302. If you were re-directing a different domain, then it could be considered a 301 - a permanent change to a different location.
I also dug up an interesting forum post on the issue that you can find http to https re-direct. One of the posts suggest using Apache Virtual Hosts to solve the issue might be a possible work-around for you if you have access.
Arnel C.
2014-10-22 9:46 pm
I've built a new site.
Some of the old site's pages have corresponding pages in the new site. Some do not.
Unless someone tells me it's a bad idea, I was planning to redirect the old pages to the new pages where they exist, and redirect the remaining old pages to the main page of my new site.
Is there a way to do that? Or are the choices:
A) redirect the whole site to a new site
B) redirect each page, individually.
2014-10-23 4:31 pm
Hello Rlchard,
Thank you for your question. First redirect the old domain to the new domain as described above. Then create a 404 redirect that will redirect the missing pages to the new domain, like this:
ErrorDocument 404 http://newdomain.com
If you have any further questions, feel free to post them below.
Thank you,
2014-10-23 3:00 pm
I have a site, where we moved the urls like this
example.com/movies/12345 ( movieid)
can you help me out with the rewrite condition please?
2014-10-23 5:27 pm
Hello Juan,
Thank you for our question. Unfortunately, I don't know an easy way to accomplish this using an .htaccess rule, unless you redirect each page individually. This is because the page names are changing from the movieid to the title-of-the-movie.
I recommend looking for a plugin, or addon for your CMS that can simplify the redirect.
Alternately, a developer should be able to custom code something in PHP, or the Database to accomplish this.
If you have any further questions, feel free to post them below.
Thank you,
2014-10-23 6:00 pm
Recently redesigned our site for http://www.logicweb.com
All previous files were .php extensions and so Google webmaster tools naturally is giving off about 150 errors because the .php old files cannot be found. This is odd because the updated sitemap with the current .html files was updated immediately upon launch, with no errors there. Why Google is still looking for the old .php files I cannot figure out.
My question is, using htaccess how can I 301 all old. php files in one instance BUT with a couple of sub-directory as exceptions to this rule? In other words, redirect all .php except logicweb.com/billing.
Thank you for any assitance.
2014-10-23 6:21 pm
Hello Chad,
Thank you for your question. You can request that Google reconsiders crawling your website, which should update the older cached URLs.
Then, you will want to redirect the individual pages (for example logicweb.com/billing) first in your .htaccess file.
Then create a 404 redirect for any errors that occur similar to this:
ErrorDocument 404 http://example.com
In this example, anyone who gets a 404 error will be redirected to example.com.
If you have any further questions, feel free to post them below.
Thank you,
2014-10-23 10:31 pm
Very helpful indeed. Also much better than other links on google since this is easy to replace for ccTLDs
2014-10-24 6:47 am
Hi there,
I can't seem to find the answer to this after a lot of searching!
I have a domain for my business, but the old owners still had their website up saying that the business was closed. I have just managed to purchase their old domain, which I have just imported. The service I use only allows me hosting individually for each domain, so in order to set up a 301 redirect for the old domain, I would need hosting for it (which is a waste of money really). I thought I could just point both domains at the same webspace, and put the 301 in to redirect from the old domain to the new, however it seems I can only use 301's for pages / directories rather than domains ... right? So, I can't do this:
Redirect 301 oldsite.co.uk/index.htm http://newsite.co.uk/index.htm
Any help would be gratefully received as I'm going round in circles here!!
2014-10-24 7:43 am
Hello Nicola,
That is very odd that your host does not allow that. Do they allow you to edit an htaccess file? I am unsure of how to do what you are asking as I do not know what they have set up on their side. You would need to ask them how to work with their existing setup to accomplish that.
Kindest Regards,
Scott M
2014-10-30 11:36 am
First just want to say great article. Now for my question, I've tried everything and just can't get this to work. How would one redirect this?
Thanks for your time.
2014-10-30 2:43 pm
Hello Chris,
Thank you for your question. Since the folder is changing, most likely you would "Redirect individual files on the same domain" as explained above.
What CMS are you using, for example WordPress, Joomla, Drupal, etc. There may also be an easier way to do this within your CMS with a plugin/addon.
Thank you,
2014-10-30 3:56 pm
Hi John-Paul,
Thank you for taking the time to respond to my question. This would be OpenCart
2014-10-30 4:19 pm
Hello Chris,
Thanks for letting us know you are using OpenCart. There are many Extensions available for handling 301 redirects in OpenCart.
You can narrow the search result down to your specific version, there is a drop down menu on the left where you can do that. You may have to test a few to decide which one you prefer.
If you have any further questions, feel free to post them below.
Thank you,
2014-10-31 1:55 am
I want to redirect my url http://www.findmovers.in/top-packers-and-movers-in-gurgaon to http://www.findmovers.in/packers movers in gurgaon. but all by url genrate daynamicaly, last sement change daynamilcaly which is a city name. how i can apply 301 redirect for all my urls.
2014-10-31 11:01 am
Hello Pradeep,
You would need to create a redirect for each domain however, it is not recommended to have spaces in your url as it can sometimes create issues with your http server. What kind of CMS are you using as there may be a plugin to do what you are looking to do.
Thank you,
TJ Edens
2014-10-31 8:00 pm
Hi guys!
It seems that you really knows about this. Thank you to help to so many people. My problem is... a long time ago I had a shopping cart and one link is linked in some external sites the link is http://www.cryo64.com/index.php?option=com_content&task=view&id=8&Itemid=26 but Some years ago I installed Zencart and the current link is "http://cryo64.com/store/wallpapers/levit-folder-manga". I'm trying REDIRECT but is not working. I have many others broken links to fix that start with "index.php?option=com_". Any clue? Thanks!
2014-10-31 8:45 pm
Hello Dario,
Thank you for contacting us. It is possible existing rules in your .htaccess file are interfering with the redirect you are adding. You may have to look through your .htaccess file for something that conflicts with this rule.
Alternately, your CMS may control the redirects for your website and be overriding your rule. In Zen Cart the best option may be to use a 3rd party Module such as Ultimate SEO URLs, or Ceon URI Mapping (SEO)
If you have any further questions, feel free to post them below.
Thank you,
2014-10-31 10:46 pm
Yes! Actually I'm using Ceon URI Mapping (SEO) . Let me show you the content of my htaccess to see if you can tell me what is doing the conflict. For me is chinese language lol. http://cryo64.com/myhtaccess.txt
Thanks for your help!
2014-11-03 11:39 am
Hello Dario,
Sorry for the problems with the re-writes. It's difficult for us to troubleshoot this issue without access to the server that's hosting you. The suggestion I was given by a senior tech who looked at the issue with me was to disable your re-writes and then test the redirects. Try disabling them one at a time until you can determine what may be interfering with the redirect. If the problem persists you may want to contact your current host and ask to see if your re-directs are causing an issue that they can identify.
Otherwise, provide us some further information after disabling the re-writes. We're looking for specific information that would have to do with re-write affecting re-directs. Error messages that you're seeing would help.
Kindest regards,
Arnel C.
2014-11-03 1:44 pm
Hi Arn, thanks a lot for your help.
I added a txt with the .htaccess content so you can find where is the error. The file is http://cryo64.com/myhtaccess.txt Thanks a lot for your help. Unfortunately my host provider only help for errors related with the hosting. I would love to have a service like you are given us to who don't have an idea about this (like me). :)
2014-11-03 2:38 pm
Hello Dario,
Sorry for the continued problems with the re-directs. When we troubleshoot them, we generally have control of the server so that we can see the rules that are working or not working based on what we have enabled or disabled. We can narrow down the cause of the problem using this approach. However, since your account is not related to an account with our hosting service, we cannot do this. You will need to delete or remove the re-writes - line by line and see what's happening with your redirect (does it work when a particular re-write is removed from your .htaccess file? We cannot do this for you because we have no access to your account.
Please step through procedure listed above in order to troubleshoot the problem. Please let us know if you have any further questions or comments.
Arnel C.
3 Points
2014-11-05 1:51 am
I renamed few pages on website to new ones:
to a
I tried all the possible ways of 301 redirect but I always got the same problem which look like this:
Or sometimes just leave it the same way without redirecting
The only other rule I have is redirect from www to non-www.
Is there something I am doing wrong?
2014-11-05 10:23 am
Sorry that you're having problems with the re-direct. Unfortunately, we can't tell what's wrong with your redirect without a little more information. Make sure that you're following our instructions on redirects: Setting up redirects in cPanel. You should be using a wildcard redirect since everything coming from your old site will be going to a corresponding file in another subdomain on your account.
If you want us to investigate it further, please provide your domain name or account user name and we would be happy to help.
Kindest regards,
Arnel C.
2014-11-07 12:54 am
first of all congrats for your site,
how can i make a 301 redirection using a shorten URL? The thing it is that is imposible for us to make a 301 redirection from old site url " http://www.asanta.com/#!trabaja-con-nosotros/ccjb " to the new site url " http://www.asanta.com/empleo/ " . Then i thought maybe with a shorten code it could work, what do you think? could you please tell us how we could do that, or if it is not necessary and we're missing something.
It is now a wordpress site, and no plugins work for this... The thing it is that the APACHE thing is not supporting characters like " !?# ". Please help us, we are desperate!
Thanks for your time,
A. Santanawww.asanta.com
2014-11-07 1:08 am
I forgot to paste my default htaccess file generated by wordpress so you can have a better idea:# BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule># END WordPress
2014-11-07 10:44 am
This looks to mostly be done on the browser side on how it handles the #!. However you can try escaping the files such as \#\! . I did find a thread on Stack Overflow regarding the same issue someone else was having.
2014-11-07 4:19 pm
the thing it is that my website with "#!" it is in WIX. So i cannot go into the coding files. Now they offer a 301 redirection, which makes possible to make a user friendly URL go to the WIX URL: example: you can make /quienes-somos and when user clicks on that, goes to /#!quienes-somos/gsdfg . But it is impossible this way to make the user friendly URLS popular for GOOGLE, since once in the website you have the ugly URLS again.
So, what could be the solution? double 301 redirection? i have to migrate to wordpress, and wix is not helping me at all.
Thanks so much
A. Santanawww.asanta.com
2014-11-07 4:36 pm
Hello Adrian Santana,
Wix would not be able to assist with changing core Apache settings as it would change for everyone on their servers. However, I would recommend moving your website to Wordpress platform for better customization options.
Kindest Regards,
TJ Edens
2014-11-07 4:55 pm
so u mean there is no way i can do my 301 redirections properly?
2014-11-07 5:08 pm
Hello Adrian Santana,
According to a WIX support page I found, their 301 redirects only work one way. You can read more on it here.
Kindest Regards,
TJ Edens
2014-11-07 5:50 pm
i though maybe changing all links in the website, and instead of making them go to a part of the website ( WHO WE ARE= /#!WHOWEARE/GSDFG, making them go to the clean USER FRIENDLY URLS (/WHOWEARE) which will redirect the user to the UGLY WIX URL (/#!WHOWEARE/GSDFG), ir order to tell google users want the USER FRIENDL URLS. Could that work? I mean, could that make GOOGLE change their default indexed URLS? It is very important for us to save our SEO since it's been so hard to get where we are with our model agency.Thanks
2014-11-07 6:09 pm
Hello Adrian Santana,
That should work for visible purposes however I found a Stack Overflow thread going over Google SEO and fragmented URLs. I would recommend going over that thread before making major changes that will possibly affect your SEO rankings.
Kindest Regards,
TJ Edens
2014-11-07 7:23 pm
why for visible purposes? if i get to make google offer my clean URLS in their results...when i'll move to WORDPRESS puting the same clean URLS, they will be indexed automatically i guess, won't they?
i think this is the only solution i can have, maybe i can try first with a concrete URL and see if google indexes it the right way, if not what do i do? I've been looking for a solution to this for weeks...if you know the way to do it with the .htaccess file please tell us. we will thank it so much, sorry for our english we're spanish,
2014-11-07 7:41 pm
Hello Adrian Santana,
Yes they should be indexed for when you move your website over to Wordpress. If Google happens to index a bad URL then you can have it removed by following steps in how to remove a webpage from Google. I was not able to find an .htaccess solution for what you are trying to do.
Kindest Regards,
TJ Edens
2014-11-07 8:47 am
I edit my htaccess file for 301 redirect:
/tin-tuc/may-tinh-bang-acer-iconia-a1.html http://blog.mysite.com/tin-tuc/may-tinh-bang-acer-iconia-a1.html
it's work ok but:
/product/bao-da-ultrabook http://mysite.com/bao-da-ultrabook.html
it not work
Please help me. Thanks
2014-11-07 10:15 am
Hello Zaki,
For your second redirect are you trying to redirect a folder to a file? Can you provide your domain so we many look into it further by chance? Have you tried doing the following?
/product/bao-da-ultrabook.html http://mysite.com/bao-da-ultrabook.html
Kindest Regards,
TJ Edens
2014-11-08 8:45 am
Hi TJEden, thanks for your reply.
I'm not redirect folder to page, it's page to page because im moving from wordpress (without html) to Opencart (with .html).
My domain: http://zaki.vn
2014-11-28 5:13 pm
Hello Zaki,
There are a few ways to do redirects as you will have noticed from all of the replies in this article and the article itself. You can use the cPanel redirect option. It creates in the re-directs in the .htaccess file for your. If that is not sufficient, then look at using a re-write re-direct. This forum post provides an example of how the re-write can be written to re-direct to a specific location based on a specific .html page.
I hope this helps to answer your question, please let us know if you require any further assistance.
Arnel C.
2014-11-08 10:07 am
If I want to have the .htaccess convert all of my .htm pages to .php and do the 301 redirect, is this the correct method? Thanks!
2014-11-10 11:13 am
Hello Grillman3000,
What you have looks very close to what I have:
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php
Give it a try and let us know.
Kindest Regards,
Scott M
2014-11-10 6:30 am
Hi I really hope you can help me please. I'm at my wits end helping a friend.
On old-domain-1.com redirecting all pages to 1 page seems to work##### REDIRECT THIS SITE TO away.html#RewriteCond %{REMOTE_ADDR} !^xxx\.x\.xxx\.xxxRewriteCond %{REQUEST_URI} !^/_css/.*$RewriteCond %{REQUEST_URI} !/away.html$ [NC]RewriteRule .* /away.html [R=301,L]
Now I'm trying to redirect everything at old-domain-2 to old-domain-1/message.html#redirect to other site, message.htmlRewriteEngine onRewriteCond %{HTTP_HOST} ^old-domain-2.comRewriteRule ^(.*)$ http://old-domain-1.com/message.html [L,R=301]
This never works because I can't work out to let message.html load in the first redirection.
Will truly appreciate any help, thanksKK
2014-11-10 8:18 am
I am beginer just learning Php these days. I'd like to simply place permanent redirection rule.
Currently my site is opening with both www.abc.com and abc.com. I'd like to place a which rule ?
Is below mentioned rule is correct ? Please advice
RewriteEngine on rewritecond %{http_host} ^abc.com [nc] rewriterule ^(.*)$ http://www.abc.com/$1 [r=301,nc]
2014-11-10 11:24 am
Hello Vineet,
We have an article about forcing www for your website. That will help you accomplish what you are looking for.
Kindest Regards,
Scott M
2014-11-12 1:10 pm
Thanks i have been looking for this information but i have an issue with this rule:
Redirect 301 /index.php?Itemid=571 /contact-us
The above didnt work question 1 is this correct, second where do i add this line in the htaccess file?
2014-11-12 2:20 pm
Hello Jay,
Thanks for the question. A Redirect rule only uses URL paths as criteria, excluding the query string. If you want to use the query string as part of the re-direct, you need to use a mod_rewrite.
If you want to match some query string and redirect all URLs to some other URL, use a RewriteCond together with a RewriteRule. Try this out:
RewriteEngine On
RewriteCond %{QUERY_STRING} Itemid=571
RewriteRule .* /contact-us [R=301]
I hope this helps to resolve your problem! Please let us know i you have any further questions or comments.
Arnel C.
2014-11-12 3:52 pm
I recently changed my htaccess file to make some dynamic urls more search engine friendly. For instance I changed www.example.com/search.php?query=truck to www.example.com/search/truck.php. I used the following htacess code to do this :
Options +FollowSymLinks
RewriteEngine on
RewriteRule search/(.*)/\.php search.php?query=$1
RewriteRule search/(.*)\.php search.php?query=$1
The above allows me to reach the example.com/search/truck.php, but I'm still confused on how to get queries from users using our site to go to the new url structure over the old one. For instance I have to manually enter example.com/search/truck.php for my browser to go there. We have a search form on the site that provides query results from our database. Since I have the SEF URL setup how do I redirect these queries to the SEF version I've already setup.
Hopefully this makes sense :-)
2014-11-12 4:10 pm
Hello Matt,
Thanks for the question. The problem you're having has to do with making sure that ALL of your URL re-writes or re-directs are put in place in your .htaccess file. These should be done with the Search Engine Friendly URLs in mind. In general - depending on the software you're using to create/run your website - this can be done from the program. For example, PrestaShop has an option that you can simply click and then it uses SEF urls. These are accomplished through code and rewrites/redirects. I can't give you specifics because providing the complete re-write or redirect code to get your site to use your SEF URLs would be beyond the scope of our support. In some cases, programs like WordPress offer plugins that provide the changed URLs for you. If your site is not that large, then you may be surprised at how many re-write rules it would take to make your website use your SEF urls - it might be far less than you think. Again, this all depends on how many SEF urls you're trying to use and how many pages you're trying to re-direct.
I hope this helps to explain the issue for you. In the case of trying to account for your entire SEF structure, you would need to provide the necessary re-direct/re-write rules to account for all of the paths that you wish to use for your website.
Kindest regards,
Arnel C.
8 Points
2014-11-12 4:18 pm
Thanks for your speedy answer (I signed up for a support name so my user name is now poultonweb). I'll continue to research this, thanks for your insight.
2014-11-18 2:57 pm
I am trying to redirect my site from www to no www I used:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.emudevs.com [NC]
RewriteRule ^(.*)$ http://emudevs.com/$1 [L,R=301,NC]
But it gives me a redirect loop, any thoughts?
2014-11-18 3:27 pm
How is your website built? Many content management systems such as WordPress have their own way of directing content which would cause this redirect loop when redirecting back using .htaccess.
2014-11-18 3:37 pm
I run through vBulletin, but I just switched my site to Apache mode instead of FCGI and it works now. Not sure why it loops through CGI.
2014-11-18 5:58 pm
Typically, you would place it within the top of your .htaccess file.
2014-11-18 7:01 pm
I need to write an htaccess for a tricky domain.
domain.org (all route files need to redirect to domain.com)
several subfolders/domains with wordpress installations
domain.org/studentcenterone (must stay as is)
domain.org/studentcentertwo(must stay as is)
domain.org/anothersubdomainone (must stay as is)
domain.org/anothersubdomaintwo (this one should redirect)
domain.org/orgba123 is returning error 404 pages everywhere I turn (wordpress install because a different developer copied the install instead of moving it and only redirected the homepage to the domain.com - need entire directory to go to domain.com
Help? can it be done?
2014-11-18 7:09 pm
To do so, simply create those folders that you need to redirect elsewhere, then place the redirect that is mentioned in this article inside each of these folders, adjusting for of course the redirect locations.
2014-11-18 7:17 pm
but how does that work for the main route of the domain then.
if domain.org has a htaccess that redirects to domain.com
anything on domain.org then redirects to domain.com those subdomains included, is there not a and/or statement that can be added in the htaccess to tell it to skip those folders/subdomains?
2014-11-18 7:41 pm
I may be misunderstanding your question. Are you attempting to only redirect specific directories, or redirect everything excluding specific directories?
2014-11-18 7:51 pm
a little of both really
domain.org needs to redirect to domain.com
but domain.org/studentcenterone stays as is
domain.org/studentcentertwo stays as is
domain.org/orgba123 redirects to domain.com (route not subdomain)
does that help?
2014-11-18 8:18 pm
This should get you started:
RewriteEngine on
The .htaccess rules above should redirect all content to the new domain, with the exception of the folders listed.
8 Points
2014-11-21 6:59 am
Hi JeffMa, I need an emergency help in .htaccess. I need to redirect all the URLs of the old website to the index page of new website. I am using Wordpress for developing the websites. Hop you will give the answer and thanks in advance....
2014-11-19 6:08 am
when i am using following urlhttp://www.bothouniversity.ac.bw/
then its working fine but when i romve www in above url it redirect to the older site
2014-11-19 11:19 am
Hello Vikas,
Sorry for the problem with the re-direct. There are unfortunately many different possible causes for the URL not to work. You should start with checking your .htaccess file and also make sure that you do not have any DNS recordss that may be re-directing the URL minus the WWW.
I did try to test the URLs you provided, but neither of them connect. If you can provide more info on your .htaccess file, then we can try to see if there is a problem.
Kindest regards,
Arnel C.
2014-11-21 8:08 am
I need to redirect all my pages and posts of "olddomain.com" to index page of "newdomain.com" using .htaccess, I tried using the code: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^olddomainn.com$ [OR] RewriteCond %{HTTP_HOST} ^www.olddomain.com$ RewriteRule (.*)$ https://newdomain.com/$1 [R=301,L] </IfModule> # END WordPress But it is redirecting to each page( ie, olddomain.com/about to newdomain.com/about ) but i need a code which can redirect all pages to index page of newdomain (olddomain.com/pages to newdomain.com ) .
Please advice me what code i have to use in .htaccess file.
2014-11-28 5:18 pm
Hello Jinsy,
You will need to remove your old re-direct code from the .htaccess file before you make any change. You can use the cPanel make a wild-card re-direct. This will re-direct all files in a folder to a single one.
I hope this helps to answer your question, please let us know if you require any further assistance.
Arnel C.
2014-11-21 10:33 am
When i add the follwoing code at the top of the page i get a a loop error, the site is based on joomla, any ideas? I ahve a number of pages to do and this is taking for ever i realy need som help in bypassing the error?
RewriteEngine On RewriteCond %{QUERY_STRING} Itemid=571 RewriteRule .* /contact-us [R=301]
2014-11-21 10:45 am
Hello Jay,
Have you tried using any Joomla plugins to perform the redirect for you? I found some Joomla Extensions that should help ease your problem.
Kindest Regards,
TJ Edens
2014-11-21 11:44 am
I already tried a number for 2.5 and dont work do you have a recommdation, i dont want to change all the urls, just 20 pages or so
2014-11-21 12:06 pm
Hello Jay,
I have used the plugin Simple Redirect to redirect articles to other pages before. I would suggest giving this a try first.
Kindest Regards,
TJ Edens
2014-11-21 12:08 pm
im not sure if we are on the same page but i want google or the user to see a url in a sef way so not just redirect the url but to change the url competely i dont really want ot use a joomla extension as im only changing a few urls, is this what we call a 301 redirect? if so how do i add the rule in the htaccess with out getting the joomla loop error
So instead of see this in the broswer
Search engines and users see this in the broswer SEF version
2014-11-21 12:23 pm
Hello Jay,
Something such as the code Im providing below should be sufficient to solve your redirect issue.
Redirect 301 /job-search/simple-search/guest/jobsby_criteria/jobcateg/1-accountancy-jobs /1-accountancy-jobs
Could you provide us your domain so we may try to troubleshoot further?
Kindest Regards,
TJ Edens
2014-11-21 12:11 pm
Hello TJEdens,
I not redirecting a article its a component so this owuldnt work as it doesnt have a page?
2014-11-21 3:01 pm
hi the site in questions is http://www.pure-jobs.com joomla platform, so just adding the above code is not working as it giving me a loop error, please help?
2014-11-21 4:22 pm
Hello Jay,
I was not able to replicate a loop issue with the redirect. You may want to contact the technical department who manage your server as there may be other rewrites causing issues. I would recommend backing up your .htaccess and start fresh with the re-writes.
Kindest Regards,
TJ Edens
2014-11-27 7:05 am
I want to redirect www.example.com/test/live/index.php/customer/account/login to www.example.com/test/live/customer/account/login.
Kindly help me to fix this.
2014-11-28 4:43 pm
Hello Karthik,
You should be able to use the cPanel redirect for that re-direct. If you have any further questions or comments, please let us know.
Arnel C.
2014-11-27 9:26 am
Helo Sir ,
I shall be thankful to you if you give me best solution for my website. I was running my website on hostgator , but sudden hacking attack on my web portal so my all files sudden destroyed. but i have 700+ index pages in google , traffic is running there but site is down , can you please tel me the solution i want to redirect all my internal index pages into main domain.
2014-11-28 5:33 pm
Hello Muhammad Irfan,
Sorry for the problems with your website. You can create what's called a wildcard redirect in a cPanel. A wild-card re-direct directs all files within a directory to a single file. I hope this helps to answer your question, please let us know if you require any further assistance.
Arnel C.
2014-11-28 7:46 am
Any one can suggest me how can redirect subdomin in www --
My one subdomin website not redirect in www. error is comming - please suggest me how can i solve this problem -- URL is http://kanpur.rankuptechnologies.in/
2014-11-28 1:20 pm
Hello shashi,
Thank you for your question. We are happy to help, but will need some additional information.
What error are you seeing? Can you provide a link to the error?
I could not identify a CMS, but it may be easier to make this change in the configuration. For example, are you using Joomla, Drupal, WordPress, etc.?
Thank you,
2014-12-02 4:54 pm
Is it possible to redirect a domain without redirecting the URLs.
I want to redirect domainA.com to domainB.com
but I do not want to redirect domainA.com/anything.html
2014-12-02 5:05 pm
If you do not want the full path to be redirected, you may use the following:
RewriteRule ^(.*)$ http://www.example.com/ [L,R=301,NC]
2014-12-03 7:46 am
Hi I wanted to redirect old HTML Pages to wordpress new pages. I tried all plugins but didnt work. Can you plz tell how to redirect via .htaccess ?
Ex : http://coachhire365.co.uk/coach_hire_aldershot.html to http://coachhire365.co.uk/minibus-hire-aldershot/
2014-12-03 1:36 pm
Hello Sid,
Thanks for the question. As per the link above you would use the page to page code, but your destination page would simply NOT have the .html extension. Please review the instructions above and let us know if you continue to have problems.
Arnel C.
2014-12-03 11:09 am
trying to set up a redirect as follows
old site used directory names
2014-12-03 1:45 pm
Hello Andy,
You can use the individual files option listed above for your redirect. You simply be replacing the conditions with URLs for your files. Please try this solution and then let us know if you have any further questions.
Arnel C.
2014-12-05 7:27 am
How to 301 redirect a full website having different url extensions?
For example, I have a Joomla website with below links
I want 301 redirect above website to new domain with below links.
I want to know, it would be enough to implement 301 code given below.
RewriteEngine on RewriteCond %{HTTP_HOST} ^mywebsite.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.mywebsite.com [NC] RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301,NC]
Should url names and url extensions be the same in new website as it is there in old website while implementing 301 redirect.
I mean http://mywebsite.com/about-us.php will be success redirected to http://newsite.com/about.html.
2014-12-05 3:02 pm
Hello Devendra,
Thank you for your question. It seems like you want to Redirect all files with certain extension.
When you are using a CMS that utilizes .htacess rules, it can cause incompatibilities with the extensions/addons you are using.
If you experience problems, Joomla has a helpful guide on Creating 301 redirects.
There are also many Joomla Extensions available to help you easily create 301 redirects in Joomla.
Thank you,
2014-12-06 5:15 am
i have problem in my php application ,
what i have need to is, redirecting users
if someone insering url with specific page such as attendence.php he can able to access is but what i have to do is, need to redirect that unauthorized user to login page, how do i do that with .htaccess file please suggest me please
2014-12-08 2:08 pm
Hello Jitendra,
One way you could put these files in a folder and restrict the folder to a user/password. This can be done by password protecting a directory.
Kindest Regards,
TJ Edens
2014-12-15 1:45 am
I want to redirect mysite.com to mysite.com/folder/ . How can i do it? well it means there is no index.php in mysite.com, and all content now have moved to mysite.com/folder/
2014-12-15 12:51 pm
Hello Skills,
Thanks for the question. In this case, you would need to re-write the URL to go to different location under the same URL. Look at Example #2 in our tutorial How to redirect a domain without changing the URL. Follow the directions and it should provide the resolution you seek.
Please let us know if you require any further assistance.
Arnel C.
2014-12-17 6:41 am
I cant anchor my articles. I tried to rewrite the code thru .htaccess.
im using camel case on anchor.
THANKS for the reply.
2014-12-17 9:53 am
Hello Victor,
From the research I have done on the subject as well as actual testing, it is not possible to perform a 301 redirect using the anchor hashtag. The hashtag is a client-side only thing and the HTTP GET request ignores it when determining the URL.
Kindest Regards,
Scott M
2014-12-18 8:41 am
Hi Scott,
It's me again. The last piece of advice you gave me worked perferctly thanks. p.s. - this blog getting lots of traffic... niiice.
Anyway, to my question... I have a website that's ranking nicely for my keywords, but the page that's showing up is mydomain.com/example/ as opposed to my homepage (mydomain.com).
While it's fantastic that my site is showing up in some way, shape or form, I would obviously prefer if my homepage was showing up. So, instead of doing more SEO etc., would it make sense for me to do a redirect from mydomain.com/example/ to mydomain.com?
Note: the content at mydomain.com is actually more applicable to any visitors who click on the mydomain.com/example/ link, so I'm not worried about bounces.
What do you think!?
2014-12-18 10:31 am
Hello Jon,
I would probably do both to make sure you get the customer to your main page if that is more relevant. The redirect will certainly get them there, but the additional SEO will help the main page eventually overtake the /example page.
Kindest Regards,
Scott M
2014-12-18 11:21 am
Hello, I wanna be able to redirect people using the domain example.me to www.example.me and I need it to be exactly the domain example.me
2014-12-18 1:02 pm
Hello Johandrex,
Thank you for your question. The best method would be to change the actual domain name in the CMS you are using.
We are happy to help, but will need to know the CMS you are using to provide a specific guide. Are you using WordPress, Concrete5, Joomla, etc.
If you have any further questions, feel free to post them below.
Thank you,
2014-12-23 6:11 am
Hi there. i think i got what i m looking there but i wanted to be sure for my solution. i m going to change theme of my html web page and links to a new responsive theme with diffrent links. Also new links will be php. i did this :
Redirect 301 /index.html /index.php
Redirect 301 /oldpage1.html /newpage1.php
Redirect 301 /oldpage2.html /newpage2.php
Redirect 301 /oldpage3 /newpage3.php
..... and it goes like this for whole pages.
also i used Rewrite in htacess too like :
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^index.html.* index.php [NC]
RewriteRule ^oldpage1.html.* newpage1.php [NC]
.... and goes like that for whole pages.
Domain will be same. Text content will be same. Only Visual part of page are gonna change. i only added some extra pages to site. Any mistakes that i did there ? Any suggestions ? i m asking because i dont want to lose rank on google. Thanks for help !
2014-12-23 9:52 am
Hello Ahmet,
The setup looks generally correct. As far as if it works or not, simply put it in play and see what it does. If it doesn't work, you will need to re-evaluate what you have. Testing it will not affect Google. Google doesn't watch a site every second so you can make changes, test them, and correct mistakes without worrying about ranking during the process.
Kindest Regards,
Scott M
2014-12-23 8:26 am
pleasepleaseplease help me! old website www.example.com/folder1/ new website www.example.com (but the new website is in folder2) big problem with old links (i want them to link to the root of my new website)
2014-12-23 10:22 am
Hello Alice,
What have you tried? What code settings are you using currently? Are they working for you? Are they not working for you?
Kindest Regards,
Scott M
2014-12-23 10:45 am
i've tried this
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !folder2/RewriteRule ^(.*)$ /folder2/$1
the main problem is with link such as http://www.example.com/folder1/oldpage.jsp.
I'd need such links to point to http://www.example.com/ since website structure is totally different!
2014-12-23 12:10 pm
Hello Alice,
The current rule you have says that if something is not in folder2, then redirect to folder2 with whatever else comes after it. However, your text says something different.
You may want to try using an htaccess redirect generator. These can help simplify things quite a bit for you. A quick search gave me this one. We have no affiliation to it, nor do we endorse it, it is simply provided as an example of this type of site to help create htaccess redirects.
Kindest Regards,
Scott M
2014-12-30 10:26 am
we are doing e-commerce site migration.. so we are going to migrate all the products to my new e-commerce site we have migrated sucessfully .. but my question is some customers may have bookmark of that old site product urls.. the migrated products contains around 2000 so how to write rewrite rule for these much products in apache when user hitting the old site product urls..
oldSite-- www.oldsite.com/product/456521/genechip
to redirect url
newSite-- www.newsite.com/product/456521/genechip
like that i have create for 2000 products its becoming tedious.. so can u produce any solution for this and i want to know how to create .htaccess file in apache..
2014-12-30 11:01 am
This rewrite rule will redirect the users from one domain to another:
RewriteEngine on
2014-12-31 7:21 am
Hi, @JeffMa
Thanksfor your reply.
I am okey with that but i want to redirect the specefice products only from the old site to new site and that could be around 200 products url so how to make as dynamic..
And i want to know how to create .htaccess file in apche server
2014-12-31 8:39 am
Hello Mani,
Thanks for the question. Making the re-directs into a dynamic solution that would automatically create the redirects is unfortunately far beyond the scope of the support center. You will need to speak with a programmer/developer for further assistance in your request - we do not provide programming services.
The instructions provided by Jeff, are for the .htaccess file as per the article above. If you have further questions on .htaccess, you can reference What is .htaccess or the .htaccess reference list for more information.
If you have any further questions or comments, please let us know.
Arnel C.
2015-01-11 11:55 pm
Thanks for the info,but please slow down the animation. I cannot keep up and actually see what is happening.
2015-01-16 1:01 am
Can you please help me. My friend's website was originally created in Front page.
I have redesigned it using wordpress.
The domain name will remain the same. www.creative-wholesale.com.
These are some of the old links.
What's the best way to make sure visitors are redirected to the new wordpress site.
Thanks in advance.
2015-01-16 11:31 am
Hello Sean,
Thanks for the question. If your customers are accessing the same exact pages as the previous, then you shouldn't have to do anything if your new WordPress website has the same corresponding pages. If they do not, then you need to create 301 re-directs for those pages that you have identified re-direct them to the new locations. You can use the tutorial above to help you create those re-directs in your .htaccess file.
I hope this helps to answer your question, please let us know if you require any further assistance.
Arnel C.
2015-01-16 1:02 am
please need soludtion from any one
i want change the the following way in my url
www. example.com/index.php/sub/
www. example.com/index.php/sub/
that means revove the slash end of the url
2015-01-16 11:27 am
Hello Shnamuga,
Sorry for the problem. To make it so that you're forcing your domain name to leave out the trailing slash, you need to use .htaccess to rewrite the URL. The .htaccess code would look like this:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^sub\. [NC]
RewriteRule ^(.+)/$ /$1 [L,R=301]
I hope this helps to resolve the issue for you. Please let us know if you have any further questions or comments.
Arnel C.
2015-01-17 4:48 pm
I have an old site(.com) that I would like forwarded to a new one (.net). That's easy enough. However, I have used that old site to host some images(lots of images) from outside of that .com address. I am using Go Daddy and when I use their forwarding then the images show up as broken links. Go Daddy is telling me they don't have any solutions to this problem. Do you have any suggestions?
Thank youCathy
2015-01-19 12:21 pm
Hello Cathy,
The issue comes from having the redirect set up at the main level, forwarding the .com to the .net. This means everything that uses .com will try to use .net. You should be able to set up an exclusion under the main redirect. For example if you have images under folders named 'images' and 'pics' then you could add the following exclusion.
RewriteCond %{REQUEST_URI} !^/(images|pics) [NC]
You can add additional folders by separating their names with a pipe symbol: |
Kindest Regards,
Scott M
2015-01-20 11:53 am
Actually I jumped the gun in asking this question. I was frustrated after talking to Go Daddy because they pretty much told me I was out of luck. When they set up a forward they actually change the ip address. That's what was causing the problem. When they changed it back(so that it wouldn't forward) I then decided to try the .htaccess method (which they said wouldn't work either). It worked. My images are still showing up AND it forwards properly. Best of both worlds! :-)
2015-02-02 6:57 pm
hello all. please i just uploaded my new wordpress site to my root folder
name is of the site folder is : bioreports
how do i point my .htt file to open the site
2015-02-02 7:05 pm
Hello ebenezer,
If you are trying to point to a subfolder that you have moved the wordpress to, take a look at our article on changing the home settings
Kindest Regards,
Scott M
2015-02-04 3:20 pm
301 .htaccess file - single old page to new page, i see above in your example -
Redirect 301 /oldfile.htm /newfile.htm
but what is the 3rd image in that gif above telling us to do?
actually, is the 2nd gif image telling us to do something else too?
are we supposed to have the "#" as shown in gif above?
thank you!
48 Points
2015-02-06 2:23 pm
Hi Xenia,
We're happy to help with a redirect issue on your website. However, the URL you provided seems to be loading fine. Are you still having the issues?
2015-02-06 5:46 pm
hi tim, the above images are only to show you screen captures of your quick moving gif instruction at the top of this page. it has nothing to do with my sites. the above links are to show you that you above instructions, i'm not clear on what i'm supposed to do. why does your instruction gif seem to show 3 diff texts into the htaccess file (as i typed above with examples, the links, the links show your instructions to us).
2015-02-06 7:03 pm
The first image is simply showing the opening of the file. The second is the content that you will place within your .htaccess file. As for the "#", this is a commented out line and would not be in place. Placing the "#" symbol would make the redirect inactive.
2015-02-07 2:01 pm
i'm a novice and when i saw your instruction gif above for individual files 301 redirect, i interpreted i should put
"Redirect 301 /oldfile.htm /newfile.htm" into the /oldfile.htm AND into the .htaccess file. but it should only be placed into the .htaccess file. thanks!
2015-02-26 5:31 pm
Hi Guys,you are doing a good job here, with all these answers ;)
I have a question about 301 redirects. How many of 301 records is ok to have in htaccess file. What amount could be to much and could harm performance and page load time? i need to add around 1000 301 records and i'm wondering if i can harm my web load time with this.
Thanks in advance ;)
2015-02-27 8:41 am
Hello Andrius,
I am not aware of any hard cap on an .htaccess file and have seen them with 50,000 or more lines. However, .htaccess files are read from top down and the more lines you have, the more chance you have of one or more rules contradicting each other. That said, as long as you are careful, I do not know that 1000 redirects would cause any malfunction.
Kindest Regards,
Scott M
2015-02-27 3:18 am
I hope you can help me because this is tricky one.... I am working on Magento with multi-store and multi language website I wanthttp://www.domain.com/index.php/store_code/parent_category/child_category/product/
Must redirect to
It is working fine if I am using: RedirectMatch 301 /store_code/(.*)/ /store_code2/$1.html
But should not redirect for other stores like http://domain2.com/index.php/store_code/parent_category/child_category/product.htmlredirecting to
2015-02-27 8:47 am
Hello Jatinder,
You may want to simply have the htaccess file ignore the directory with the second site. To ignore a directory, say a folder named 'abc' for example, use the following code at the top of the htaccess file.
RewriteRule ^abc - [L,NC]
This should allow it to ignore any rules thereafter for the 'abc' folder. You can then have a different .htaccess in the 'abc' folder so that directory has its own rules.
Kindest Regards,
Scott M
2015-03-04 6:50 am
very good demo show very very helpfull !!!!
2015-03-06 5:38 pm
Hi everybody, I have moved recently my site from Joomla! to WordPress.
To collect and resolve 404 errors I'm using Redirection plugin. But the plugin have an issue on the links with inside a space (es old link: www.wedding-photographer-in-italy.com/weddings/rome/russian-italian-civil-marriage-in-capitoline-hill-with-anastasya-cristiano/itemlist/date/2014 6 24.html), and the next day I have another time the same 404 error. I have also tried to put %20 on the spaces, but on the looooong links I can't know where is the space because the plugin cut the view of links with (...).
So, I have a lot of links like this:
http://www.wedding-photographer-in-italy.com/weddings/rome/russian-italian-civil-marriage-in-capitoline-hill-with-anastasya-cristiano/itemlist/date/2014 6 24.html
and I want try to catch "with-anastasya" to have a redirect link like this:
This is what I have tried on htaccess:
RewriteEngine On
RewriteCond %{QUERY_STRING} /(.*)\b
with-anastasya?\b(.*) [NC]
RewriteRule ^(.*)$ http://www.wedding-photographer-in-italy.com/weddings/russian-italian-civil-marriage-capitoline-hill-rome/$1 [R=301,L]
but don't work :(
I will apreciate any help if is possible to do my request.Thanks
2015-03-08 10:49 pm
I would like to suggest to stay away from using spaces in file names to prevent this kind of issues. I think your query string is slightly off. Trying something like below:
RewriteEngine On RewriteCond %{QUERY_STRING} ^id=([0-9]*)$ RewriteRule ^page\.php$ http://mydomain.site/page/%1.pdf [R=302,L]
Best Regards,
TJ Edens
2015-03-10 5:34 pm
have high ranked page but manufacturer changed product name so i want keep rank points. create the new product page/name/url and redirect the old high ranked page to the new page/product. i did get the 301 method, working just fine because of good instructions above but i was also reading you guys' posts and wondered if i could also do a... example:
RewriteRule ^pagefour/ pagefive/ [L,R=301]
1. does google transfer ranking points from page to page or only site to site?
2. want to make this permanent and then delete the old product after google/bing has had time to pick new page up and transfer ranking points.
3. do i also need code like i see in some posts "RewriteEngine On"
thank you!
2015-03-11 12:54 am
Hello TheBoatPeople,
That should work just fine, the rankings do transfer when you do a 301 redirect. I would suggest leaving the 301 redirect in but you can remove the old product once the 301 is in place. Also you do need the RewriteEngine On code in your .htaccess file for these to work.
Best Regards,
TJ Edens
2015-03-11 12:36 pm
with rewrite i get a 404 on all pages except the front page. searching a little i see some talk about editing httpd.conf cause apache isn't loading? i really want to get the Rewrite working/learn because i can see it is very powerful allowing conditions and such! thank you!
Redirect 301 /301pageredirect/pageone /301pageredirect/pagetwo (this works without the Rewrite code)
RewriteEngine on (as soon as i add these 2 lines i get 404 not found on all pages except front)
RewriteRule ^pagefour/ pagefive/ [L,R=301]
2015-03-13 12:35 pm
Hello TheBoatPeople,
I'm sorry for the delay in answering your reply. For some reason, however you posted your reply, it didn't show up on our list of un-answered questions/posts.
The Rewrite rules that you say cause your 404 errors usually runs based on particular conditions (set in the .htaccess file) Can you please provide the code that's in your .htaccess file? We would need to see all of it in order to determine WHY it's not working.
Kindest regards,
Arnel C.
2015-03-13 3:23 pm
Redirect 301 /301pageredirect/pageone /301pageredirect/pagetwo
RewriteEngine on
RewriteRule ^pagefour/ pagefive/ [L,R=301]
on http://innovasunny.com/
the Redirect line by itself works fine
i've searched, that higher or lower directory level .htaccess files can effect other .htaccess files? so i don't know if my primary .htaccess can effect an addon domain?
2015-03-18 12:40 pm
Hello TheBoatPeople,
Apologies that your question got passed over in our comment responses. In terms of the .htaccess files. If they're in the same directory structure as another, the higher level .htaccess file can take precedence over an .htaccess file that is in sub-directory. In order to fix that, you need to remove the .htaccess file that is affecting your subdomain. Or, you may need to delete all of the rules in it that affect your add-on domain in that .htaccess file.
If you need to keep the rules in that .htaccess file for any other directory/website, you may need to move those rules into a local .htaccess file for those specific websites (or directories). It may involve duplicating the .htaccess rules in several different .htaccess files.
I hope this helps to answer your question, please let us know if you require any further assistance.
Arnel C.
2015-03-18 1:01 pm
hi arn,
i think something else is wrong. http://innovasunny.com .htaccess file only has
RewriteEngine on
RewriteRule ^pagefour/ pagefive/ [L,R=301]
and all pages except the front page show a 404. remove the RewriteEngine code and everything works fine. put in a Redirect 301 /301pageredirect/pageone /301pageredirect/pagetwo and works fine. i never had any issues with .htaccess files effecting other directories (i just read some junk). i also read that a cause is the server is not configured for Rewrite?
RewriteEngine on
RewriteRule ^pagefour/ pagefive/ [L,R=301]
is exactly to all your help examples above in its most basic form and should work cause i have the IMH VPS setup. i have no knowledge or ability to have changed the IMH default setup so the examples on this support page should work?
thank you for any help!
2015-03-11 1:15 pm
Space the animated examples out a little more. Otherwise it's perfect.
2015-03-13 6:33 pm
I use a host which does not have a cPanel - how would I write a similar .htaccess to move a page in its own folder - to a different page ( where the "old page" content has been added) in the same folder.
and the same question to a page in a different folder.
My site has 98 pages - but I can move content to other pages and reduce to around 70 page - so that a quite a few redirects to write!
2015-03-16 5:05 pm
Hello Art2015,
You can perform mass redirects when redirecting to another site or even a directory within the same site. To redirect a page to another page within the same folder, you would need to do them individually.
Kindest Regards,
Scott M
2015-03-26 12:04 am
Do you know if .htaccess is allowed in virtual servers? So far no redirect functions!
My server is a Linux platform and the "engine' is Apache - but no cPanel no access to the rewrite module
2015-03-30 5:10 pm
I think the problem I had with my 1&1 hosted virtual server... was the the "main" Apache server not set to allow .htaccess to function because after a world tour of websites and forums to get any advice - after asking the hosts IF they had checked the settings( reportedly "default") on their Apache server - suddenly I found the 301 redirects functioned as they should!
Most advice and help did not seem to understand I had no access to the Apache rewrite module or whateverit is.
Thanks to inMotion and all who offered advice.
2015-03-15 4:05 pm
Hi, I have two domain names, example.ca and example.com, the .ca domain has an ssl certificate so it's obtained at https://example.ca. The example.com domain is an addon domain without its own webspace and I have a redirect that looks like this:
RewriteEngine on RewriteCond %{HTTP_HOST} ^example.com [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule ^(.*)$ https://example.ca/$1 [L,R=301,NC]
which seems to work fine. The problem comes in when someone types https://example.com (which doesn't exist, only the .ca uses https) and they are told they're going somewhere unsafe. For some reason it isn't redirecting that. Can you help?
2015-03-16 1:05 pm
Hello Lloyd,
That is the correct procedure as the protocol is checked prior to the redirect running.
Kindest Regards,
Scott M
2015-03-20 9:52 am
We are migrating an e-commerce site from SPIP to Magento. The new magento Urls are SEO-friendly and we are trying to redirect the old dynamic Urls from SPIP to Magento for maintaining the SEO of the old site. we are not changing the domain name.
So the problem is the redirection part.... Please help us find a solution for redirecting the following url patterns...
Thanks in advance!
2015-03-23 9:03 am
Hello Frank,
You will want to take a look at the Magento back office and create redirects there with the redirect tool. If you have more than a handful you may want to look into a Bulk 301 redirect plugin. We also found an article that talks about bulk 301 redirects.
Kindest Regards,
Scott M
2015-03-20 12:00 pm
I am confused about 301 redirects. My website is created as http://----.com. There currently is no http://www.---com. Yet from Google Analytics I receive messages saying that I have redundant searches as both versions which affects my page ranking. I have placed a 301 redirect on my htaccess file now for the http://---.com. But is that it? Do I only place a 301 rediect on a site specific for www. to redirect to non-www? Does placing the 301 rediect on my site which is a non-www verision do any good. Sorry but this was the reason why I left my previous web hosting site because they do not provide 301 redirects.
2015-03-23 9:17 am
Hello Jeff,
The .htaccess file will run no matter whether the site is attempting www or non-www version. As the server reads the file, it will come across your code to force the non-www and then switch it to that version, which is the one that Google will register.
Kindest Regards,
Scott M
2015-03-22 11:39 pm
Hi All,
I have to redirect about 40 urls, and cpanel won't do it correctly, keeps dropping arguements off the source URL, and I have been told this will need to be done via htaccess.
An example of the redirects:
source: http://www.jupiter2lightmover.com/category.php?id_category=2
redirect to: http://www.jupiter2lightmover.com/index.php?route=product/category&path=170
Cpanel confirms the redirect on the confirmation screen correctly, but when I go to the list of redirects in cpanel, the source URL is only showing as:
it "drops" the trailing "?id_category=2" off the source URL. Seems it only registers the url up to the end of the php file, but I need to redirect a whole bunch of individual urls. The target URL being redirected to seems to be correct.
Can anyone assist me please?
2015-03-23 9:28 am
Hello Adam,
cPanel is doing it right. The redirect directive does not allow string parameters. cPanel is stripping it off since it would cause failure.
You will need to use the %{QUERY_STRING} variable. In an attempt to use your given example you would write it like as the following:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id_category=2$
RewriteRule ^/?product\.php$ http://www.jupiter2lightmover.com/index.php?route=product/category&path=170 [L,R=301]
I am not quite sure about your path in the last line, but the %{QUERY_STRING} portion is correct.
Kindest Regards,
Scott M
2015-03-24 3:55 pm
I have no access to apache rewrite and no cPanel. My server is on Linux platform and "shared" hosting. The hosting company - 1&1 say the "main" server is Apache and will run .htaccess - I have followed the tutorial here to redirect single pages - Google master tolls forum can offer no help..... 1 & 1 suggested I try here!!!
Having trouble
2015-03-24 5:21 am
thanks scott. but i need rewrite rule in .htaccess. can u pls tell me the rewrite rules for following links.
2015-03-24 3:36 pm
Hello Frank,
You may want to re-think how you would like the new url would look as for that you would need to do this for multi urls. What system does your website run on?
Best Regards,
TJ Edens
2015-03-24 12:44 pm
i've stripped down to the most basic Rewrite and it 404s my entire site except the front page. with my very limited knowledge, guessing, search says could be my server is not set up for Rewrite? i want to get to Rewrite working
RewriteEngine on
RewriteRule ^pagefour/ pagefive/ [L,R=301]
thank you!
2015-03-24 3:38 pm
Hello Lee,
I would suggest letting wordpress handle the redirects instead of trying to hand write them.
Best Regards,
TJ Edens
2015-03-24 10:16 pm
Kevin L at Tier 1 support figured it out. he said i was missing the basic wordpress code. he put the only this code
in the site's .htacces file and the rewrite works, no 404 on any pages i see
RewriteEngine on
RewriteRule ^pagefour/ pagefive/ [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
thanks imh you guys are the best!
2015-03-28 2:05 am
What are the impacts of redirecting old website to new website?
2015-03-30 9:26 am
Hello Jaffer,
When you do a 301 redirect, it tells the search engines that this is the new destination for the page. This helps search engines understand there is not duplicate content and they will not penalize you for it.
Kindest Regards,
Scott M
2015-03-28 6:25 am
When my mail domain name is typed in maildomain.net, it successfully gets redirectd to my 404.shtml page; however, when the url includes index.html, e.g. maildomain.net/index.html it gets redirected to my primary domain server. primarydomain.com.
How can I update my htaccess file so that when someone types in maildomain.net/index.html it redirects them 404.shtml?
Thanks in advance for the help.
2015-03-30 9:30 am
Hello Eddie,
You will likely want to use wildcards for anything after the subdomain URL. We do not yet have an article on using wildcards in your URL but you can find specific examples by doing a search for your particular situation.
Kindest Regards,
Scott M
2015-03-30 1:48 pm
Thanks Scott,
Everything works fine now. I had two problems: Syntax and wilcards.
You guys are great!!!
Post a Comment
337 Questions & Comments
Back to first comment | top
Need more Help?
Ask the Community!
Current Customers
|Click to Chat Now
|Submit a Support Ticket