Forum Moderators: phranque

Message Too Old, No Replies

Nice URL,, search engine friendly, without php extension

         

NomikOS

1:42 am on Apr 30, 2005 (gmt 0)

10+ Year Member



Yes, I want "Nice URL, search engine friendly without php extension and subdomains"

My goal is process URLs like:
siteType.domain.com/subSiteName
siteType.domain.com/subSiteName/view/doc/123
Ex:
community.domain.com/programmers/view/doc/123 (without index.php)
business.domain.com/superFish/list/doc/456 (without index.php)

Until now I used URLs like :
siteType.domain.com/index.php/view/doc/123

The code that follow is explained inself and I use it to have $_GET properly


...
define('LOADER', '/index.php');
...

if ($_SERVER['REQUEST_METHOD'] == 'GET')
{
# make $_GET to hand
if (!strstr($_SERVER['REQUEST_URI'], LOADER . '?'))
{
$_get = explode('/', $_SERVER['REQUEST_URI']);
$deep = count($_get);

for ($i = 2; $i < $deep - 1; $i++)
{
$_GET[$_get[$i]] = $_get[++$i];
}

if (!strstr($_SERVER['REQUEST_URI'], LOADER))
{
$_SERVER['REQUEST_URI'] = LOADER."/main/main";
}
}
else
{
$_request_uri = '';
$_get = strtok($_SERVER['REQUEST_URI'], '?');
$_get = strtok('');
$_get = explode('&', $_get);

foreach ($_get as $i => $_get2)
{
$_get2 = explode('=', $_get2);
$_GET[$_get2[0]] = $_get2[1];
$_request_uri .= "/{$_get2[0]}/{$_get2[1]}";
}

$_SERVER['REQUEST_URI'] = LOADER."/$_request_uri";
}
}

Now, how can I do all this with htaccess? :o

1) avoid URLs with?, &, =
2) using subdomains
3) without index.php

How can I redirect any fileName without php extension to index.php?

jd01

2:57 am on Apr 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The question you asked is multi-level and could turnout to be complicated... very complicated.

Normally, the people in the forum help with coding, we do not code on request. I would suggest starting with the Apache documentation:

[httpd.apache.org...]

Then review the posts here to get an idea of what you will need to do. Each scenario you asked about is possible, but will have to be addressed separately, yet structured to function as a whole.

When you have what you think you need, then post the code you think will work, or have tried and know doesn't, and someone here will help you find the answers you need.

Justin

NomikOS

5:12 pm on Apr 30, 2005 (gmt 0)

10+ Year Member



You right. I'll return soon.

NomikOS

3:30 pm on May 4, 2005 (gmt 0)

10+ Year Member



This solution is working now:

RewriteEngine on
# all requests without extension go to index.php
RewriteRule!(\.(.*))$ index.php [NC]

This manner prevent problems with CSS and javascript!

Bye.-

NomikOS

4:25 pm on May 4, 2005 (gmt 0)

10+ Year Member



Complement this topic with [webmasterworld.com...] about subdomains issues :)