I have a page at http://site.com/services/ and I just want to redirect it to http://site.com/servics/first-service/
Whats the best redirect to do this and how do I do this?
PHP:
header("Location: yourpage.php");
exit;
You have to use exit
or die
after header
in order to stop execution of your code. Also, the code has to be executed before any output.
HTML:
<meta http-equiv="refresh" content="0;url=yourpage.php">
The code should be placed between <head></head>
tags.
JavaScript:
window.location = "yourpage.php";
.htaccess:
Redirect 301 /oldpage.php /newpage.php
in javascript: window.location = "/first-service";
Have you tried javascript window.location = "http://site.com/servics/first-service/";
? I hope it works.
This can be accomplished with a simple Redirect directive.
Redirect /services /services/first-service
You can choose what kind of a response code you will send to the client. Further info on that on the link I provided.
If it is a permanent change, you want to use a 301 redirect google has some good content on the matter
To build the redirect just add
redirect 301 /services/ http://site.com/services/first-service/
to .htacess on the top level of your directory tree. NOTE I switched 'servcs' from your example to services
I use this as an Index file in the folder's that I don't want the public to brows,,,,
<meta name="robots" content="noindex, nofollow" />
<meta name="googlebot" content="noindex, nofollow" />
<?php
$url = 'http://' . $_SERVER['HTTP_HOST']; // Get the server//
header('Location: ' . $url, true, 301); // Use either 301 or 302//
?>