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

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 11-01-2009, 11:00 AM   PM User | #1
FWDrew
Regular Coder

 
FWDrew's Avatar
 
Join Date: Apr 2008
Location: Missouri
Posts: 380
Thanks: 38
Thanked 45 Times in 43 Posts
FWDrew is on a distinguished road
[RESOLVED]Do I need a rewrite?

Hey Everyone,

I come to you with what I think is a reason to use .htaccess or some kind of rewrite. I admit upfront that my knowledge on this topic is limited.

Here's what I got:

I'll be moving a clients entire website and blog system to a different location on his server. Right now he has blog posts like so:

Code:
http://www.clientssite.com/blog/2009/10/26/r-i-p-geocities/
When the move is made, the URL will now look like this:

Code:
http://www.clientssite.com/2009/10/26/r-i-p-geocities/
Is there a way to detect the blog section of the URL, and remove/rewrite it to redirect to the address without blog in the URL? Does what I'm asking make sense?

I would appreciate any tips or links that could help me out.

-Drew
__________________
Dev-Tips.com || Employee at the Envato Network || My Portfolio

Last edited by FWDrew; 11-02-2009 at 07:03 AM..
FWDrew is offline   Reply With Quote
Old 11-01-2009, 01:17 PM   PM User | #2
abduraooft
Master Coder

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: God's own country
Posts: 8,976
Thanks: 142
Thanked 1,192 Times in 1,184 Posts
abduraooft is a jewel in the roughabduraooft is a jewel in the roughabduraooft is a jewel in the roughabduraooft is a jewel in the rough
Have a try by adding a rule in your .htaccess file like
Code:
RewriteRule ^blog/(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Edit:
Quote:
Is there a way to detect the blog section of the URL, and remove/rewrite it to redirect to the address without blog in the URL? Does what I'm asking make sense?
Which is your blog engine - wordpress? If so, I think there's an option to change the url under "permalinks"
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Users who have thanked abduraooft for this post:
FWDrew (11-01-2009)
Old 11-01-2009, 01:55 PM   PM User | #3
FWDrew
Regular Coder

 
FWDrew's Avatar
 
Join Date: Apr 2008
Location: Missouri
Posts: 380
Thanks: 38
Thanked 45 Times in 43 Posts
FWDrew is on a distinguished road
Quote:
Originally Posted by abduraooft View Post
Have a try by adding a rule in your .htaccess file like
Code:
RewriteRule ^blog/(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Edit:
Which is your blog engine - wordpress? If so, I think there's an option to change the url under "permalinks"
I'll give that a try, thanks abduraooft

Yes it is WordPress, I already had the idea of changing the permalinks to contains blog, but this will cause problems with other blog posts, with the way I have the client taking advantage of posts. Basically, changing the permalinks to include blog isn't an option.

I'll try this soon and get back to you, thanks again.
__________________
Dev-Tips.com || Employee at the Envato Network || My Portfolio
FWDrew is offline   Reply With Quote
Old 11-02-2009, 06:52 AM   PM User | #4
FWDrew
Regular Coder

 
FWDrew's Avatar
 
Join Date: Apr 2008
Location: Missouri
Posts: 380
Thanks: 38
Thanked 45 Times in 43 Posts
FWDrew is on a distinguished road
Hey abduraooft,

That worked wonderfully thanks. However, I come to you in need of another rewrite help.

I have a URL like so:

http://blog.clientsites.com/files/geocities.jpg

Which I would like to redirect to:

http://clientsites.com/files/geocities.jpg

Any idea or pointers on how to go about doing this?

EDIT - Nevermind, I figured everything out. I just put an .htacess file in the blog.clientssites.com folder and redirected where I needed to.

Thanks again!
__________________
Dev-Tips.com || Employee at the Envato Network || My Portfolio

Last edited by FWDrew; 11-02-2009 at 07:01 AM..
FWDrew is offline   Reply With Quote
Old 11-02-2009, 11:05 AM   PM User | #5
oesxyl
Senior Coder


 
Join Date: Dec 2007
Posts: 4,658
Thanks: 374
Thanked 562 Times in 551 Posts
oesxyl has a spectacular aura aboutoesxyl has a spectacular aura about
Quote:
Originally Posted by FWDrew View Post
Hey abduraooft,

That worked wonderfully thanks. However, I come to you in need of another rewrite help.

I have a URL like so:

http://blog.clientsites.com/files/geocities.jpg

Which I would like to redirect to:

http://clientsites.com/files/geocities.jpg

Any idea or pointers on how to go about doing this?

EDIT - Nevermind, I figured everything out. I just put an .htacess file in the blog.clientssites.com folder and redirected where I needed to.

Thanks again!
you get it wrong. You don't need any redirection, blog is a subdomain of clientsites.com, like anything is before clientsites.com( for example www, ), so all you need is to add a subdomain and put wordpress there.
And also it can have any subdomain name you want, blog is just a name,

best regards
oesxyl is offline   Reply With Quote
Users who have thanked oesxyl for this post:
FWDrew (11-02-2009)
Old 11-02-2009, 12:56 PM   PM User | #6
FWDrew
Regular Coder

 
FWDrew's Avatar
 
Join Date: Apr 2008
Location: Missouri
Posts: 380
Thanks: 38
Thanked 45 Times in 43 Posts
FWDrew is on a distinguished road
Quote:
Originally Posted by oesxyl View Post
you get it wrong. You don't need any redirection, blog is a subdomain of clientsites.com, like anything is before clientsites.com( for example www, ), so all you need is to add a subdomain and put wordpress there.
And also it can have any subdomain name you want, blog is just a name,

best regards
I'm aware of what you mean, but thank you

It's really a complicated project and thing to explain (I have trouble describing it all in type), but it's all figured out now, I didn't need to use a rewrite for the second example.
__________________
Dev-Tips.com || Employee at the Envato Network || My Portfolio
FWDrew is offline   Reply With Quote
Reply

Bookmarks

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 04:35 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.