Page 1 of 1

[htaccess] Domain Pointers

Posted: Tue Apr 05, 2005 6:47 pm
by Gen-ik
Hi guys!

It has been a while since I last visted.. looks like a few things have changed around here. :) Anyway, I need some help with a bit of htaccess that I can not for the life get to work properly.

I have a domain name pointing to the root directory of my server, and I'm currently checking the HOST_NAME using PHP and redirecting it to the correct folder where the site contents are stored.

For example, mydomain.com is pointing to myserver.com which checks the HOST_NAME and directs the visitor to mydomain.com/website/

What I am trying to do is create a bit of htacess code that will remove the /website/ bit from the URL. For example,

mydomain.com/website/ would actually be displayed in the browser as mydomain.com/
and mydomain.com/website/news/ would be displayed as mydomain.com/news/

I don't have access to the .conf file on the server otherwise that would be the easiest way to sort this out.

Hope that makes sense. ;)


PS. Code so far...

Code: Select all

RewriteEngine on
RewriteBase /
RewriteCond %{HOST_NAME} ^www.mydomain.com$ їOR]
RewriteCond %{HOST_NAME} $mydomain.com$
RewriteCond ${REQUEST_URI} !^/website/(.*)$
RewriteRule ^(.*)$ /website/$1 їL]
...I think that's right anyway. I don't have the actual .htaccess file handy at the moment.

If anyone knows how to do this I would be very happy. :D

Posted: Tue Apr 05, 2005 6:56 pm
by feyd
was playing around with this sort of thing this morning..

Code: Select all

RewriteEngine on
RewriteCond %{SERVER_NAME} ^(www\.)?mydomain\.com$
RewriteCond %{REQUEST_URI} !^/website/
RewriteRule ^(.*) /website$1 їL]
I think...

Posted: Tue Apr 05, 2005 7:56 pm
by Gen-ik
Cheers mate. Looks like I was on the right track then.

One thing I did notice was that I could just type "mydomain.com/website/" into the browser location and it would still go there.. ie, it didn't change to "mydomain.com/".

I found a way around that though with this...

Code: Select all

if(stristr($_SERVER["REQUEST_URI"], "/website/") !== false) {
  $split = explode("/website/", $_SERVER["REQUEST_URI"]);
  header("location:/{$split[1]}");
  exit;
}
...and it all seems to be working fine now.