Page 1 of 1

SEO URL - reduce length of URL

Posted: Sat Dec 11, 2010 9:50 am
by werendle
[text]I have created search engine friendly URL's from my dynamic ones so "/index.php?page=home" now displays as "/index/page/home", is there are way of getting it to work with "/home" instead[/text]

Code: Select all

<ul class="menu">
	<a href="/dev/index/page/home">Home</a> &nbsp;&nbsp;&nbsp;&nbsp;<img src="images/present.png" height="38" width="35" alt="Logo"/>&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="/dev/index/page/hints">Hints & Tips</a> &nbsp;&nbsp;&nbsp;&nbsp;<img src="images/present.png"height="38" width="35" alt=" logo"/>&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="/dev/index/page/occasions">Occasions</a> &nbsp;&nbsp;&nbsp;&nbsp;<img src="images/present.png" height="38" width="35"alt=" logo"/>&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="/dev/index/page/blog">Blog</a>&nbsp;&nbsp;&nbsp;&nbsp;<img src="images/present.png" height="38" width="35"alt=" logo"/>&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="/dev/index/page/about">About</a> 

	
</ul>
<br>
<?php
	$page = $_GET['page'];
 		switch($page) 
			{
				case('home'):
					include ("home.php");
				break;
				case('about'):
					include ("about.php");
				break;
				case('occasions'):
					include ("occasions.php");
				break;
				case('blog'):
					include ("blog.php");
				break;
				case('hints'):
					include ("hints.php");
				break;
				default:
					include ("home.php");
			}
?>
[text]I have looked into the HTML Base tag, but not sure where to start, any help would be appreciated thanks[/text]

Re: SEO URL - reduce length of URL

Posted: Sat Dec 11, 2010 3:06 pm
by Jonah Bron
We don't know, we can't see your .htaccess (assuming you used mod_rewrite).

P.S. you don't have to put your message in [text][/text ] tags.

Re: SEO URL - reduce length of URL

Posted: Sun Dec 12, 2010 2:09 am
by werendle
Hi, .htaccess now attached, sorry I missed it out

Code: Select all

RewriteEngine On

RewriteRule index/(.*)/(.*) index.php?$1=$2

Re: SEO URL - reduce length of URL

Posted: Sun Dec 12, 2010 5:50 pm
by Jonah Bron
This should work:

Code: Select all

RewriteEngine On

RewriteRule index/(.*) index.php?page=$1

Re: SEO URL - reduce length of URL

Posted: Sun Dec 12, 2010 7:00 pm
by werendle
Hi Jonah, thanks for the reply, maybe I am missing something or have asked the wrong question.
with the current rewrite I have changed the displaying url from http://www.mydomain.com/index.php?page=home to http://www.mydomain.com/index/page/home which is much more friendly to the user, but what I am looking to achieve is http://www.mydomain.com/home. is it possible to use the mod rewrite to remove the /index/page/ from the url altogeather?
Thanks again for your help, Regards Will

Re: SEO URL - reduce length of URL

Posted: Sun Dec 12, 2010 7:10 pm
by Jonah Bron
Ah, then this should work.

Code: Select all

RewriteEngine On

RewriteRule (.*) index.php?page=$1

Re: SEO URL - reduce length of URL

Posted: Sun Dec 12, 2010 7:28 pm
by werendle
Hi again, I have tried the change suggested, each link then returns the default case from indexp.php, I then tried changing the href link removing the /page/index and still no joy. Any other sugestions? many thanks again :?

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 11:33 am
by Jonah Bron
Put an echo statement in index.php so we can find out what it's getting.

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 11:44 am
by werendle
Hi Jonah, what do you need to be echoed?

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 12:04 pm
by Jonah Bron
$_GET['page']

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 12:17 pm
by werendle
Ok, url http://mydomain.com/dev/getstarted
echo output index.php

In index.php the default case statement is set to ('home')

Can I PM you the proper URL to take a look?

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 12:21 pm
by Jonah Bron
Sure, you can. But I just need to know what $_GET['page'] exactly contains...

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 12:33 pm
by werendle
Jonah Bron wrote:Sure, you can. But I just need to know what $_GET['page'] exactly contains...
The Echo request displays 'index.php'

I have mailed you the url if that helps,

Thanks again

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 1:50 pm
by Jonah Bron
Hm, well, I haven't had too much experience with mod_rewrite. Perhaps someone more knowledgeable in that area can help you... sorry :(

Cheers.

Re: SEO URL - reduce length of URL

Posted: Mon Dec 13, 2010 2:21 pm
by werendle
Hi Jonah, no problem, thank you so much for taking the time to have a look, best regards

Will