Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Need help with .htaccess rewrite

 
   Web Hosting Problem Solving Community! (Home) -> Apache RSS
Next:  Apache22 FreeBSD Install and Virtual Hosts not wo..  
Author Message
rverrips

External


Since: May 10, 2006
Posts: 3



(Msg. 1) Posted: Wed May 10, 2006 1:37 am
Post subject: Need help with .htaccess rewrite
Archived from groups: alt>apache>configuration (more info?)

Hiyee

I've been googling for a whole day now and can't find a decent
example/guide/howto on the various variables, and functions available
for Rewriting and Redirecting using only a .htaccess file.

I have one host with multiple domain names (it's hosted, so I need to
make changes in the .htaccess file)

The host is domain1.com, and what I'm hoping to achieve is just to
redirect hits to the root of domain2.com to domain2.com/subdir and
still present in the browser as domain2/subdir (At present, hits to
the root of domain2.com present as domain1.com, but domain2.com/subdir
works fine)

All the rewrite rules I've tried either rewrite my entire domain1.com
to domain2.com as well, or don't present in the browser as
domain2.com/subdir, but rather only as domain2.com

And ideas where I can find some decent doc's on writing .htaccess files
as I'm aware I need to do some exclusions to get this working

Thanks

Roy

 >> Stay informed about: Need help with .htaccess rewrite 
Back to top
Login to vote
rverrips

External


Since: May 10, 2006
Posts: 3



(Msg. 2) Posted: Wed May 10, 2006 2:41 am
Post subject: Re: Need help with .htaccess rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks for the quick reply Robert

I'm not sure what you mean with internal and external - Both the hosts
are on the same apache server ... (internal, no?)

Could you explain why the www is in brackets, and what the ^ and ?
represent?

Thanks

Roy

 >> Stay informed about: Need help with .htaccess rewrite 
Back to top
Login to vote
Robert Ionescu

External


Since: Jan 19, 2006
Posts: 142



(Msg. 3) Posted: Wed May 10, 2006 10:59 am
Post subject: Re: Need help with .htaccess rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

rverrips wrote:
> The host is domain1.com, and what I'm hoping to achieve is just to
> redirect hits to the root of domain2.com to domain2.com/subdir and
> still present in the browser as domain2/subdir

So you're looking for an external (visible) redirection?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com
RewriteRule ^$ /subdir/ [R=301,L]


to keep this internal, you could use

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteRule ^(.*) /subdir/$1 [L]

--
Robert
 >> Stay informed about: Need help with .htaccess rewrite 
Back to top
Login to vote
Paul Lautman

External


Since: May 10, 2006
Posts: 2



(Msg. 4) Posted: Wed May 10, 2006 11:10 pm
Post subject: Re: Need help with .htaccess rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

rverrips wrote:
> Thanks for the quick reply Robert
>
> I'm not sure what you mean with internal and external - Both the hosts
> are on the same apache server ... (internal, no?)
>
> Could you explain why the www is in brackets, and what the ^ and ?
> represent?
>
> Thanks
>
> Roy

^(www\.)?domain2\.com

This is a regular expression. The ^ means that this is the beginning of the
url string. The ? means match this if it occurs zero or one times. The
"www." is inside brackets to indicate that the ? is referring to the whole
string "www." Without the brackets, it would refer only to the ".".
So this expression says match www.domain2.com or domain2.com but do not
match something.domain2.com or something.www.domain2.com.

HTH

Regards
Paul
 >> Stay informed about: Need help with .htaccess rewrite 
Back to top
Login to vote
rverrips

External


Since: May 10, 2006
Posts: 3



(Msg. 5) Posted: Thu May 11, 2006 1:21 am
Post subject: Re: Need help with .htaccess rewrite [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks Paul, The explaination of ? and ^ helped me a lot and I've been
able to do what I was hoping for ...

Kudos

Roy
 >> Stay informed about: Need help with .htaccess rewrite 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
.htaccess rewrite - Hello. I'm trying to redirect all requests from http://domain1.com/* to http://domain2.com/* I have the following in my .htaccess file in the doc root of domain1.com: RewriteEngine on RewriteCond %{REQUEST_URI} !-U RewriteRule ^(.+) ..

.htaccess and Rewrite... - I'm trying to give a permanent redirect for a directory that I moved the path to and I'm having trouble figuring it out. Old: http://forum.server1.com/general/ New: http://forum.server1.com/general-new-subject/ Any assistance would be greatful.... I....

Rewrite with .htaccess, php on linux - I am trying to achieve this solution of having pages served statically by the web server. The URL rewriting is occuring, but I can't get the server to output the file as an .html page. Is there something similar in .php to force the output of the query t...

rewrite conditions in .htaccess - Hi there, I am wondering how to write a condition which is true for http and https I tryed to replace the s with *, but this did not work as expected. Have a look: RewriteCond %{HTTP_REFERER} !^http*://www.servername.*$ [NC] Is there a special..

htaccess rewrite question - What would be the htaccess syntax to redirect requests as such? Request http://personalweb.example.com/~user Rewrite to http://personalweb.example.com/user/ Basically just removing the tilde. Thanks
   Web Hosting Problem Solving Community! (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]