Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 10-27-2009, 09:33 AM   #1 (permalink)
Junior Member
 
Jamz's Avatar
 
Join Date: 10-14-09
Location: England
Posts: 11
iTrader: 0 / 0%
Latest Blog:
None

Jamz is liked by many
Mod Rewrite help

Hi All,

Right im having a bit of bother trying to get this to work...

I have two websites:

website1
website2

Now both domain names point to the same web server, but i would like website2 to redirect to another directory on the server, but act as if that directory was the base directory of the site

So.... you visit www.website2.com and it redirects you to www.website2.com/website/index.php but i want the user to see www.website2.com/index.php in the url bar

Now i dont want everything to transfer to website2 as website1 is my main site, and i would like website2 to be another site completely but running on the same server.

Hopefully you will understand

Cheers

James
Jamz is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 02:30 PM   #2 (permalink)
Moderator
 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 1,291
iTrader: 2 / 100%
Latest Blog:
None

ScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest order
If you have cPanel or DirectAdmin and are allowed addon domains you can convert the second site to an addon domain.

I also can tell you how to it with webmin.
__________________
These forums are as good as the posts that you contribute to them.
~~
ScriptMan
Webmaster Help Articles
Domains & Sites For Sale by Owner
ScriptMan is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 02:40 PM   #3 (permalink)
Junior Member
 
Jamz's Avatar
 
Join Date: 10-14-09
Location: England
Posts: 11
iTrader: 0 / 0%
Latest Blog:
None

Jamz is liked by many
There is an admin panel, but nothing to allow me to say what domain points where... the only way to do it is via htaccess... but I'm quite new to htaccess and not sure how to code what I'm after
Jamz is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 03:43 PM   #4 (permalink)
Junior Member
 
Join Date: 10-19-09
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

error 404 is liked by many
I would try this .htaccess in the main site :
Code:
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www.website2.com$ RewriteRule ^(.*) /website2/$1 [L]
Jean-Luc
__________________
Broken Link Checker >> www.200ok.eu
error 404 is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 04:46 PM   #5 (permalink)
Junior Member
 
Jamz's Avatar
 
Join Date: 10-14-09
Location: England
Posts: 11
iTrader: 0 / 0%
Latest Blog:
None

Jamz is liked by many
Quote:
Originally Posted by error 404 View Post
I would try this .htaccess in the main site :
Code:
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www.website2.com$ RewriteRule ^(.*) /website2/$1 [L]
Jean-Luc
Hmm that didnt work... im already running the below code on the website:
Quote:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.signhereuk\.com$ [NC]
RewriteRule ^(.*)$ http://www.jamessimpson.co.uk/website/signhere/$1 [R,NC,L]
But i want signhereuk to look as if its on its own web host
Jamz is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 05:06 PM   #6 (permalink)
Junior Member
 
Join Date: 10-19-09
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

error 404 is liked by many
As long as you have this
Code:
RewriteCond %{HTTP_HOST} ^www\.signhereuk\.com$ [NC] RewriteRule ^(.*)$ http://www.jamessimpson.co.uk/website/signhere/$1 [R,NC,L]
all hits on http://www.signhereuk.comsomething will be replaced by hits on http://www.jamessimpson.co.uk/website/signhere/something. You need to remove these lines to make it work.

Did you try a .htaccess with just the following:
Code:
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.signhereuk\.com$ [NC] RewriteRule ^(.*) /website/signhere/$1 [L]
What error do you get if it does not work ?

Jean-Luc
__________________
Broken Link Checker >> www.200ok.eu
error 404 is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 05:55 PM   #7 (permalink)
Junior Member
 
Jamz's Avatar
 
Join Date: 10-14-09
Location: England
Posts: 11
iTrader: 0 / 0%
Latest Blog:
None

Jamz is liked by many
i get an Internal Server Error using what you have said above
Jamz is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-27-2009, 07:56 PM   #8 (permalink)
Contributing Member
 
mr.joebert's Avatar
 
Join Date: 04-07-08
Location: Clearwater, FL USA
Posts: 91
iTrader: 0 / 0%
mr.joebert is liked by somebodymr.joebert is liked by somebodymr.joebert is liked by somebody
Any time your replacement URL in RewriteRule begins with "http", the server automatically sends either a 302 (temporary, and default) or 301 (permenant, must be specified) external redirect. Basically it just makes RewriteRule function like a Redirect directive, instead of an alias like you want. So you'll not want to include the http.

Once you get that out of the way, you're left with a path to the subdirectory and a pattern to match. One thing you need to remember is that after the URL is matched and the rewrite is done, mod_rewrite sends the modified URL back through the list of rewrites again to see if it matches anything else in its' new form.

Chances are the reason your getting an internal server error has something to do with an infinite loop. "(.*)" is a generic pattern, it will ALWAYS match any URL that it's tested against. Because of this it means your rewrite depends on the RewriteCond directives to tell it when to stop.

In your case, since your RewriteCond for the HTTP_HOST will also always match your URL in this case, it doesn't know when to stop. You can use a RewriteCond that checks for the path addition to stop the loop.
mr.joebert is online now  
Add Post to del.icio.us
Reply With Quote
Old 10-28-2009, 12:45 AM   #9 (permalink)
Junior Member
 
Join Date: 10-19-09
Posts: 13
iTrader: 0 / 0%
Latest Blog:
None

error 404 is liked by many
mr.joebert is right 100%.

Code:
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.signhereuk\.com$ [NC] RewriteRule ^(?!website\/signhere\/)(.*) /website/signhere/$1 [L]
should avoid the infinite loop.

Jean-Luc
__________________
Broken Link Checker >> www.200ok.eu
error 404 is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-28-2009, 05:25 AM   #10 (permalink)
Junior Member
 
Jamz's Avatar
 
Join Date: 10-14-09
Location: England
Posts: 11
iTrader: 0 / 0%
Latest Blog:
None

Jamz is liked by many
Quote:
Originally Posted by error 404 View Post
mr.joebert is right 100%.

Code:
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.signhereuk\.com$ [NC] RewriteRule ^(?!website\/signhere\/)(.*) /website/signhere/$1 [L]
should avoid the infinite loop.

Jean-Luc
That works spot on, cheers Jean-Luc!
Jamz is offline  
Add Post to del.icio.us
Reply With Quote
Old 10-28-2009, 03:19 AM   #11 (permalink)
Contributing Member
 
Join Date: 02-20-08
Posts: 56
iTrader: 0 / 0%
Bompa is liked by many
Quote:
Originally Posted by Jamz View Post
Hi All,

Right im having a bit of bother trying to get this to work...

I have two websites:

website1
website2

Now both domain names point to the same web server,
That confuses me right there.

Typically, when you register a new domain name, you do not point it
to a web server, but to DNS name server IPs that your hosting provider
gives you.

If you're on a shared hosting account, no amount of tinkering with htaccess
will do what you are asking.


It really sounds like you need to set up an AddOn Domain. Look again at
your admin cpanel. KEEP looking at it until you see ADDON DOMAINS
or just ADDONs. Click AddOn Domains, then put in the second domain name.
TAB to the next field. It will create a folder of the same name. Done.

It's quite simple to add a domain.

Even if you have a dedicated IP, which is very unlikely unless you have
a VPS or dedicated server, htaccess will still probably NOT do what you are
asking because before the request gets to htacess, it goes through the
vhosts in httpd.conf. When it finds no entry for domain2, it will .... give
some sort of error.

Bompa
Bompa is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do the MOD REWRITE? ashokkumar SEO Forum 1 08-03-2009 01:00 PM
301 asp rewrite? bomy Coding Forum 10 06-19-2007 03:05 AM
How to do rewrite like v7n Antonio Coding Forum 3 04-01-2006 04:19 AM
need help with mod rewrite url rewrite sim Coding Forum 3 07-31-2005 07:51 PM
Mod Rewrite T-Kai Coding Forum 5 08-24-2004 11:42 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 03:40 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.