Follow Me on Twitter
Client Support Community Server Status Contact Us Client Login
Email Hosting Website Hosting Reseller Hosting VPS Hosting Dedicated Servers

    Join our Community      Check your private messages       Profile       Search       FAQ       Memberlist       Log in


How can I show one URL but serve content from another?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Sep 25, 2009 10:10 am    Post subject: How can I show one URL but serve content from another?
 
I would like to show http://www.example.com/ in the address bar, but display content from http://www.example.com/new/

Can I do this with mod_rewrite?

Thanks.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
NetHosted - Darryl Reply with quote
 NetHosted Staff

 

 Joined: 24 Jun 2005
 Posts: 1019
 

PostPosted: Fri Sep 25, 2009 11:08 am    Post subject:
 
Hi,

This is possible yes, I believe this should work:

Code:
Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/new%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ /new/$1 [QSA,L]


replacing new and example with your site and the subfolder, thanks!

Regards,

Darryl

_________________
| Darryl Taylor
| Technical Support & Sales Manager, NetHosted Ltd.
| Resellers, take a look at overselling !
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Sep 25, 2009 12:11 pm    Post subject:
 
Thanks Darryl. I was actually just looking for a special case rule that would only affect those two urls.

I don't need example.com/one.htm to show example.com/new/one.htm for example. I'm guessing that's what those rules will do (?).

Thanks.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
NetHosted - Darryl Reply with quote
 NetHosted Staff

 

 Joined: 24 Jun 2005
 Posts: 1019
 

PostPosted: Fri Sep 25, 2009 12:53 pm    Post subject:
 
Hi,

Here's the solution, apologies for taking a while, I had to research this myself!

Code:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(index\.html)?$ new/ [L]


Regards,

Darryl

_________________
| Darryl Taylor
| Technical Support & Sales Manager, NetHosted Ltd.
| Resellers, take a look at overselling !
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Sep 25, 2009 2:37 pm    Post subject:
 
Nope, that doesn't seem to work and I'm still confused by all this mod_rewrite stuff. I have yet to find a site that explains it in simple enough terms

It would probably be easier for me to adjust my php templates to work around this, but I've often wondered how/if it could be done, so I'd like to find out.

Basically the page I want the user to see when they visit example.com is at example.com/index/ (index.php in that directory).

I don't want to redirect them, I want them to stay at example.com but see the page which is stored at example.com/index/

I don't have an example.com/index.html (or .php) page (I did try adding one, but that didn't help).

Any more ideas?

Thanks.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Fri Sep 25, 2009 2:44 pm    Post subject:
 
Richard,

Where are you trying to do this?

Thanks,

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
paulmarson Reply with quote
 NetHosted Customer

 

 Joined: 26 Jan 2005
 Posts: 498
 Location: Midlands

PostPosted: Fri Sep 25, 2009 2:57 pm    Post subject: Re: How can I show one URL but serve content from another?
 
UserFriendly wrote:
I would like to show http://www.example.com/ in the address bar, but display content from http://www.example.com/new/

Can I do this with mod_rewrite?

Thanks.

Richard


Would
Quote:
<frameset rows="*" framespacing="0" border="0" frameborder="NO">
<frame src="http://www.your domain" name="domain_content" scrolling="auto" noresize>

</frameset>
<noframes>
<body>
</body>
</noframes>

work to refirect to a full frame instead ???
If you do a resirect from somewhere like dot tk thats the way they do it and it always has www.domain.com for any page you look at.
Or use a dot tk free domain to do it for you (good if you cant get the exact .co.uk or .com domain you want)

_________________
Paul M
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Sep 25, 2009 3:10 pm    Post subject:
 
Thanks Paul, but I'd really like to avoid using frames.

NetHosted - Andrew wrote:
Where are you trying to do this?

The actual address is http://www.southeringtons.co.uk/ but at the moment I'm working in http://www.southeringtons.co.uk/new/

Thanks.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Fri Sep 25, 2009 4:18 pm    Post subject:
 
Richard,

I have implemented Darryl's suggested rules into the correct place in your .htaccess file:

Code:
RewriteCond %{HTTP_HOST} ^southeringtons\.co.uk [OR]
RewriteCond %{HTTP_HOST} ^www\.southeringtons\.co.uk
RewriteRule ^(index\.html)?$ new/ [L]


it works as expected for me.

Thanks,

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Sep 25, 2009 4:44 pm    Post subject:
 
Thank you Andrew and Darryl, that does what I want. I was trying to get it to work inside the subfolder I was working in and obviously didn't adjust it to account for that. I'll have another play about with it next week to see if I can get my head round it.

Thanks again.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Thu Oct 01, 2009 4:25 pm    Post subject:
 
I have this set up now and it's working great. Thanks for your help guys.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Thu Oct 01, 2009 4:26 pm    Post subject:
 
No problem!

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Oct 02, 2009 11:42 am    Post subject: More mod_rewrite Stuff
 
Hello. Me again. I have some more mod_rewrite questions related to my original request so I thought I'd just continue here.

At our other site, moonremovals.co.uk I have some urls that need redirecting to new, improved urls. I'll probably do this the same way I did with our main site (southeringtons.co.uk) on a per url basis. For example:

RewriteRule ^contact.htm$ http://www.southeringtons.co.uk/contact-us/ [R=301]

At the same time, I would like to reorganise the actual files so I end up with each page as an individual .php file in the root directory (for example, moonremovals.co.uk/contact-us.php), but still I want people to access the pages from the new, improved urls as above (moonremovals.co.uk/contact-us/).

I'll name the php files appropriately so that the same rule can be use for all of them (/contact-us.php to /contact-us/ ... /downloads.php to /downloads/ etc...).

To summarise:

If people visit moonremovals.co.uk/contact.htm redirect them to moonremovals.co.uk/contact-us/ and show them content from moonremovals.co.uk/contact-us.php

If people visit moonremovals.co.uk/contact-us.php redirect them to moonremovals.co.uk/contact-us/ and show them content from moonremovals.co.uk/contact-us.php

If people visit moonremovals.co.uk/contact-us/ don't redirect them, just show them content from mooremovals.co.uk/contact-us.php

How would I go about doing this? I hope it all makes sense.

Thanks.

Richard

_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
NetHosted - Andrew Reply with quote
 NetHosted Staff

 

 Joined: 22 Mar 2004
 Posts: 7017
 

PostPosted: Fri Oct 02, 2009 1:20 pm    Post subject:
 
Hi,

I don't really think you need mod_rewrite here.

If you never advertise moonremovals.co.uk/contact-us.php anywhere on your site then no one will know it's there, you therefore always link everywhere to moonremovals.co.uk/contact-us/ and simply place the contact-us.php file in the /contact-us/ directory and add a DirectoryIndex entry to a .htaccess file in the directory so the server knows to read from the contact-us.php file. If you want to have contact-us.php in the root of your public_html to work on then you can just create a symlink to it from the /contact-us/contact-us.php file.

You can then just redirects to change the contact.htm file over to the /contact-us/ directory.

Thanks,

Andrew

_________________
| Andrew Bassett
| Managing Director, NetHosted Ltd.
| Follow us on Twitter: http://twitter.com/nethosted 
| Members, tell us what you think  of NetHosted!
Back to top
View user's profile Send private message
UserFriendly Reply with quote
 Community Liason

 

 Joined: 05 May 2005
 Posts: 212
 Location: Nottingham

PostPosted: Fri Oct 02, 2009 2:08 pm    Post subject:
 
Okay, that sounds interesting... However, it sounds like the directories would be required (correct me if I'm wrong ) which is one thing I'm trying to avoid.
_________________
http://theunusualsuspect.com/
Back to top
View user's profile Send private message Visit poster's website
Post new topic   Reply to topic    NetHosted Community Index -> Web Design
Goto page 1, 2  Next
Page 1 of 2

User Permissions
You cannot post new topics in this forum
You cannot 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
You cannot attach files in this forum
You can download files in this forum

 
Jump to: