Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP and 301 redirect

Posted on 2011-02-18
5
Medium Priority
?
236 Views
Last Modified: 2013-11-19
I thought 301 redirecting some dynamic pages would be as simple as putting the following code at the top of my dynamic page:

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.firstclasscomponents.com" );
exit(0);

Open in new window



However it seems this is not the case since it produces a 302 instead.

Basically the dynamic page has a url that looks like this http://www.mysite.com/AD9505Z2.html

and the AD9505Z2 is part of a what gets queried in the database so that the records information is used in the page.

I use a .htaccess file to do the rewrite. So that looks like this:

RewriteRule (.*)\.html /part_info.php?url=$1

Open in new window


Well the page works fine, but I actually wanted to wipe out all the pages from google and do a 301 to the home page of the site. However everything I have tried has just produced 302's. Does anyone have any thoughts. I have tried all kinds of different things and nothing is working.

0
Comment
Question by:tarrigo
[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
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:andreizz
ID: 34926089
<?header( "HTTP/1.1 301 Moved Permanently" );header( "Status: 301 Moved Permanently" );header( "Location: http://adress/" );exit(0); ?>

Open in new window


this works
0
 
LVL 11

Expert Comment

by:VanHackman
ID: 34926141
The code that you have provided is correct.

Also you could try to do a httacess redirection:


Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Please REPLACE www.newdomain.com in the above code with your actual domain name.

Open in new window

0
 

Author Comment

by:tarrigo
ID: 34926689
Unfortunately those solutions did not work. Still get the same problem. It keeps coming back with the following results:

Checked link: http://www.mysite.com/AD9505Z2.html

Type of redirect: 302 Found

Redirected to: http://www.mysite.com/ZiUfZ/AD9505Z2.html 

0
 
LVL 11

Accepted Solution

by:
VanHackman earned 1000 total points
ID: 34929330
In this case is more probably that your server is ignoring the configurations.
Because the solutions provided above are quite enough for what you are needing.
Ask your hosting provider about if it does have some restriction regarding this kind of redirection.

because whithout looking at the real site I'm unable to help you better... =P


Kind regards,
VanHackman
0
 

Author Closing Comment

by:tarrigo
ID: 36372093
Didn't solve the problem, but it might have guided down the right road.
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

609 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