Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-30-2011, 03:58 PM   PM User | #1
Coastal Web
Regular Coder

 
Coastal Web's Avatar
 
Join Date: Oct 2004
Posts: 225
Thanks: 12
Thanked 3 Times in 3 Posts
Coastal Web is an unknown quantity at this point
Post mod rewrite help

Hey guys, l have a quick mod rewrite question that l was hoping someone could help me out with.

I've got wildcard subdomains setup in cpanel on my account.
I've got a directory called ebook, with several sub directories in it
/ebook/subdir1
/ebook/subdir2
/ebook/subdir3


Now l'm trying to setup a mod rewrite that will redirect:
subdir1.domain.com to domain.com/subdir1.

Now l'm using the following htaccess rules:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com[NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9.-]+)\.domain\.com
RewriteRule (.*) ebook/%1 [L,QSA]
and it's working in this way:
subdir1.domain.org redirects the user to:
subdir1.domain.org/ebook/subdir1
Which works, but the url string looks like it does above and l was hoping that l could do the same, without having the actual URL show in the address bar.

Any help would be greatly appropriated!
Coastal Web is offline   Reply With Quote
Old 08-30-2011, 06:45 PM   PM User | #2
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
What you already have, in essence appears to be correct. Since you aren't specifying a domain on the target path, it should do a rewrite not a redirect. I would guess this is something to do with what your RewriteBase is, placing a forward slash before the word e-book may work, but I doubt it. Try installing a plugin for FireFox such as TamperData, this will intercept all requests. Since you say the URL is changing you should probably see that when you make the request, you recieve a 301/302 redirect which your browser is following. I'm not sure why you should be receiving this though. If you are then I'd have a play around with RewriteLog.
Cags is offline   Reply With Quote
Reply

Bookmarks

Tags
htaccess, mod rewrite, redirect

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 08:34 PM.


Advertisement
Log in to turn off these ads.