williamsongibson
williamsongibson

Reputation: 277

One page with two urls?

What is the best/standard way of using one page at 2 urls?

In the menu we have home, about, services we offer, contact.

On the services section, it is split in to 4 sub sections.

So the page you land on services.php, is also the same as services1.php

Is there a way with .htaccess or php to duplicate the page so if you visit http://www.mysite.com/services.php or http://www.mysite.com/services1.php you end up at the same page?

Upvotes: 0

Views: 77

Answers (3)

Oussama Jilal
Oussama Jilal

Reputation: 7739

Just use an htaccess with these lines in your root directory :

RewriteEngine on
RewriteBase /
RewriteRule ^services1\.php$ services.php [QSA,L]

Upvotes: 1

Delon
Delon

Reputation: 253

If you're talking about avoiding duplicating your code, why not simply include the one page in the file for the other page? So services.php would be where you maintain your code, while in services1.php you just have a one-line include:

<?php include('services.php'); ?>

Upvotes: 1

Carsten
Carsten

Reputation: 18446

A quick and simple way would be to leave services.php as it is and just include it in services1.php:

<?php
    include("services.php");
?>

Or, you could use Apache's mod_rewrite like this (in your Apache configuration or .htaccess):

RewriteEngine  on
RewriteRule    ^/services1\.php$  /services.php [PT]

Upvotes: 1

Related Questions