On Page 301 redirect for html pages
-
For php pages youve got
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.example.com" );
?>Is there anything for html pages? Other then
Or is placing this code redirect 301 /old/old.htm http://www.you.com/new.php in the .htaccess the only way to properly 301 redirect html pages?
Thanks!
-
Yeah - htaccess is the way to go for rewrite rules. Check out http://www.seomoz.org/learn-seo/redirection for more depth/detail, too.
-
I am suprised no one is recommending using the httpd.conf file. It functions the same as the.htaccess file except it is much more efficient because it is loaded into the servers memory which means the file is opened & read once. With an .htaccess file the server reads the file on every request.
Also, if PHP is enabled on the server you can use php code in html pages. There is a php or server setting where you can say read html pages as php.
-
I have a lot (100+) of 301 redirects to do for .html pages, is the .htaccess the only way to go?
Thanks
-
Just make sure not to use this for a whole ton of 301 redirects. If it is a big enough redirect project using PHP might be the way to go.
-
My vote gose to the htaccess any time all the time.
It's global, you can add all the rewrite rules within the same global file.
Is just my opinion.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
301 redirects delay in picking up
Hi I have been involved in the redesign/development of a website which has up until now had a lot of international traffic. On day of migration I uploaded all the 301 redirects to the website (wordpress) using Simple 301 redirect plugin. I tested a number of them and they appeared to be working. I also submitted the new sitemaps to Search Console. Since migration international traffic - particularly from countries such as india, Phillipines, Sri Lanka etc have significantly dropped off whereas the local traffic and some of the international traffic such as USA has remained fairly consistent. Looking at Analytics and entrances recently it appears as though search results are/were showing a number of pages with 404's (one in particular which received significant traffic and for which I had created a 301 redirection) - I have checked this page using the old url and it re-directs correctly for me and today asked a colleague in India to also check - he is getting the redirection fine. Does Google.in take a significantly longer time to pick these up in search results? Or am I missing something?
Technical SEO | | musthavemarketing0 -
Redirecting 301 or 302?
Hi, I think the part of this question has been already discussed, but not exactly the same, I think. My site requires authentication for member page. When a user try to go to member area, we redirect to 3rd party to do the authentication. 1. user clicks a link to www.mysite.com/member/contents.html
Technical SEO | | HypermediaSystems
2. www.myauthenticate.com/login?h=somehashuniquehash454859428778545 (enters id/pass)
3. login success => redirect back to www.mysite.com/member/contents.html We are doing it 302, temporary redirect. But moz crawler error seems to suggest we should do it 301.
So my question is:
A. Should we do it 301???
B. If we do 301, what happens to myauthenticate.com? since it has hashtag, I am afraid it could create a lot of duplicate contents on myauthenticate.com side... Thank you so much for your help in advance...0 -
Is 301 redirect replacing or adding PA on a page ?
Hello Moz community, I am re-structuring information architecture on a website. The homepage targets keyword A
Technical SEO | | Sindicic_Alexis
There is a page /page-on-B/ that targets keyword B
There is also an older page /page-on-kinda-B/ that targets a keyword which is really close to B ( i think they should have been worked on the same page...) I want to re-optimise the homepage on keyword B because i know it is worth the effort. If i re-write the homepage to talk about B and do a 301 redirect of : /page-on-B/
/page-on-kinda-B/ to the homepage is it going to add page authority to the homepage ? is it the right way to proceed ?
Thanks for your support !0 -
Where is the 301 redirect?
Hi, in the last week I take an issue for 301 permanent redirect for a subfolder in the main website! In that folder i have a index.php file for a google map fullscreen edition and the only link who connects the wordpress website with the subfolder is only a direct link! Is that an error of seomoz app or something else? Thanks 1.jpg
Technical SEO | | petrospan0 -
Could a URL change path conflict a 301 redirect?
Hi Mozzers, We create multiple pages for one of my client. Some of them are replacing old pages. I setup 5 of them out of 40. I was able to set them live via the drupal CMS. The new pages were actually published but didn't have any URL but had nodes in directory such as www.example.com/node298. To set them live i changed the url path to one page that already existed( www.example.com/old). In order to setup the replacing page: www.example.com/node298 i added the same name as the old one but in order to avoid URL conflicts with new page(www.example.com/new) I had to change the old page's url path as well such as www.example.com/old2) I know i have to 301 redirect the old to the new obviously but my question is: does a URL path change on the old page www.example.com/old matters in when 301 ing it? will it still transfer all the juice to the new page Visual Process: Main goal: www.example.com/old redirect to www.example.com/new but these two are exactly the same url So modification of URL path: www.example.com/old to www.example.com/old2 to avoid URL conflict Therefore www.example.com/old2 =www.example.com/old (just url change path difference) Question: Because of this url change, will a 301 from www.example.com/old2 to www.example.com/new will still carry all the juice that www.example.com/old carried or not? I hope i didn't make it too confusing. Let me know if it is the case Thanks Mozzers Ty
Technical SEO | | Ideas-Money-Art0 -
Redirects 301
Hello, I need to reedirect a URL of a page that I have in my site (http://digitaldiscovery.com.pt/servicos-de-marketing-digital/publicidade-online/) to a new URL with SEO porpuses. Whats the best way to this? I use Wordpress btw. Tks in advance! PP
Technical SEO | | PedroM0 -
What tools produce a complete list of all URLs for 301 redirects?
I am project managing the rebuild of a major corporate website and need to set up 301 redirects from the old pages to the new ones. The problem is that the old site sits on multiple CMS platforms so there is no way I can get a list of pages from the old CMS. Is there a good tool out there that will crawl through all the sites and produce a nice spreadsheet with all the URLs on it? Somebody mentioned Xenu but I have never used it. Any recommendations? Thanks -Adrian
Technical SEO | | Adrian_Kingwell0 -
Why is a 301 redirected url still getting indexed?
We recently fixed a redirect issue in a website, and although it appears that the redirection is working fine, the url in question keeps on getting crawled, indexed and cached by google. The redirect was done a month ago, and google shows cached version of it, even for a couple of days ago. Manual checking shows that its being redirected, and also a couple of online tools i checked report a 301 redirect. Do you have any idea why this could be happening? The website I'm talking about is www.hotelmajestic.gr and its being redirected to www.hotel-majestic.gr
Technical SEO | | dim_d0