?
Solved

,htaccess 301 redirect

Posted on 2016-10-03
10
Medium Priority
?
52 Views
Last Modified: 2016-10-31
Hello,

What will be 301 redirect code in .htaccess for:

abc.com/html/xyz/oxo.html   To >   abc.com/asd/qwe/luv/

Thanks.
0
Comment
Question by:tahirr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 2000 total points (awarded by participants)
ID: 41827391
Assuming that the path is fixed, try this:
RewriteEngine On
RewriteRule ^html/xyz/oxo\.html$ /asd/qwe/luv/ [R=301,NC,L]

Open in new window


If parts of the URL are variable, you'll need to indicate which ones.
0
 

Author Comment

by:tahirr
ID: 41827404
Thanks Terry for a super fast reply. Moved the hosting few hours ago and propagation should be done soon then I will try your suggestion and let you know.

Thanks.
0
 

Author Comment

by:tahirr
ID: 41828248
Good Morning,

I have tried this code now and it does not redirect :(
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 35

Accepted Solution

by:
Terry Woods earned 2000 total points (awarded by participants)
ID: 41828705
Ok, there's a process to go through when it's not working as expected.

The first parameter to RewriteRule is a pattern for matching the URL. We can relax the pattern until we do get a match, and then tighten it up again once we understand why.

I find when I'm testing these rules in Chrome it tends to cache or remember redirects that have previously been applied. What seems to help is to open a new Incognito/Private window each time I test a pattern. Once the page has redirected, I close all Incognito tabs/windows and open a new one to do a fresh test. You might like to try this technique too.

Firstly, try this:

RewriteEngine On
RewriteRule (.*)/oxo\.html$ /asd/qwe/luv/?from=$1 [R=302,NC,L]

Open in new window


The .* part of the pattern matches anything, so provided you try to access anything ending with /oxo.html it should redirect. If not, then it's not the RewriteRule that's going wrong.
0
 
LVL 35

Expert Comment

by:Terry Woods
ID: 41828706
Note that you should test this kind of thing on a development server before putting it live.
0
 

Author Comment

by:tahirr
ID: 41829049
Thanks for your time and detailed explanation. I will try your suggestions tonight and let  you know how it went.

One confusion if you could clear will me it even easier for me. If we redirect the old page by placing html 301 redirect code in header. Will it still transfer the SEO juice to new page or will it effect it? Do you think 301 redirect works the same in either .htaccess or css redirect or html redirect?

Thanks.
tahir.
0
 
LVL 35

Assisted Solution

by:Terry Woods
Terry Woods earned 2000 total points (awarded by participants)
ID: 41829054
If you're talking about using an HTML header refresh, then in my understanding that isn't a 301 redirect, so no it won't transfer the SEO. You need to use the .htaccess.

For a live page, you should always test with a R=302 (temporary redirect) until you're sure you've got it right, otherwise you can permanently send traffic to the wrong place. 301 = permanent.
0
 

Author Comment

by:tahirr
ID: 41829063
Thanks
0
 

Author Comment

by:tahirr
ID: 41867735
I am sorry for not posting my results. Human nature, we come back to check on status when need help and get lazy once problem is solved. : (

I was not able to use your code, for some reason it was not working. My site had gone live for two days at the point and I was in panic mode to loose SEO juice and did not want to risk that by waiting for further solution. I found a plugin for wordpress and it did solve my issue.

I am sure the information in this post will help someone in the future. It could be me making some mistake trying to implement it.

Thanks for your help. Kudos. : )
0

Featured Post

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question