Browsing at http://url.madsass.dk, open index in url dir

Discuss practical ways rearrange URLs using mod_rewrite.

Browsing at http://url.madsass.dk, open index in url dir

Postby Madsass » Fri Mar 11, 2005 9:10 am

Hey All.
Im using this code in my .htaccess file >
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^(.*)$ /index.php?p=$1 [QSA]

And this in my index.php where my content should be included >
<?
if (isset($_GET['p']) && !empty($_GET['p'])) {
$page = $_GET['p'];
} else {
$page = "news/nyheder";
}

if (eregi("/$",$page)) {
$page = substr($page,0,strlen($page)-1);
}

$filename = "/customers/madsass.dk/madsass.dk/httpd.www/".$page.".php";

if (file_exists($filename)) {
include($filename);
} else {
include("/customers/madsass.dk/madsass.dk/httpd.www/404/index.php");
}
?>

Then my question is. What should i do with my codes if i want to do this:
If i type: http://url.madsass.dk
Then, this file should be included: http://www.madsass.dk/url/index.php.

It's because i want the index.php file in url/ to be including when i'm using dir.domain.com

Thanks in advance.
Madsass
 

Postby Caterham » Fri Mar 11, 2005 10:08 am

don't use -F, use -f instead. F will perform a subrequest, bot f won't

Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?p=$1 [QSA,L]


What should i do with my codes if i want to do this:
If i type: http://url.madsass.dk
Does your subdomain point to http//www.madsass.dk (root of subdomain == root of maindomain) or to http//www.madsass.dk/url/?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby Madsass » Fri Mar 11, 2005 11:08 am

Caterham wrote:don't use -F, use -f instead. F will perform a subrequest, bot f won't

Code: Select all
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?p=$1 [QSA,L]


What should i do with my codes if i want to do this:
If i type: http://url.madsass.dk
Does your subdomain point to http//www.madsass.dk (root of subdomain == root of maindomain) or to http//www.madsass.dk/url/?

When im going to: http://url.madsass.dk/
I will have the code to open http://www.madsass.dk/url/index.php in my php page :)
Madsass
 

Postby Madsass » Fri Mar 11, 2005 11:11 am

-f and -F doesn't change anything :S
Madsass
 

Postby Caterham » Fri Mar 11, 2005 2:56 pm

-f and -F doesn't change anything :S
It will change the fact, that no subrequest would take place to check if the file exsists or not. And this is a performance issue.

When im going to: http://url.madsass.dk/
I will have the code to open http://www.madsass.dk/url/index.php in my php page
I know that this should be achieved. But a solution depends upon where your subdomain points to:
Does your subdomain point to http//www.madsass.dk (root of subdomain == root of maindomain) or to http//www.madsass.dk/url/
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 29 guests

cron