0

I'm currently using the following to redirect only 3-4 pages to new a site

# Use PHP5.4 as default
RewriteEngine On
RewriteRule ^news1\.html$ https://www.example.com/news1.html [R,L]
RewriteRule ^news2\.html$ https://www.example.com/news2.html [R,L]
RewriteRule ^news3\.html$ https://www.example.com/news3.html [R,L]


Options -Indexes

However only news.1html is being redirected, not the rest of them.

How do i redirect all to their subsequent new page?

8
  • In theory, this should work just fine! I would try and remove the escape from news1.html though. It may not be necessary. It is technically correct of course. Also the ,L may not be necessary though also technically correct. Try these one at a time to see if that makes a difference. But before doing this, clear your browser cache to make sure you are not getting the page from cache.
    – closetnoc
    Feb 15, 2015 at 19:41
  • Could you tell me the code? As im not too familiar with htaccess. Redirect 302 /news.html example.com/news1.html used more than once does not seem to work either, should i be entering something at the end of each line of code? Feb 15, 2015 at 19:46
  • First, I would tell you to empty your browser cache. This is likely the problem. Not sure how to do this for all browsers, but with Chrome, you would click on the icon in the upper-right hand corner that looks like three bars and go to More tools, then Clear browsing data. Your code is technically correct. Or at least I am not seeing anything wrong with it.
    – closetnoc
    Feb 15, 2015 at 19:51
  • Sorry about that, it was a cache issue. Feb 15, 2015 at 20:31
  • Instead of RewriteRule ^index\.html$ example.com [R,L], how do i make it so index.html and www.oldsite.com is redirected to www.example.com? Is it ^(index\.html)?$ ? old site is current webpage which index.html belongs to. Feb 15, 2015 at 20:32

1 Answer 1

1

The easiest way to do this isn't with rewrite rules but with the redirect directive. Simply use

Redirect 301 /oldfile.htm http://example.net/newfile.htm

in your .htaccess file to redirect a single file from the current site to a file on another domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.