homepage Welcome to WebmasterWorld Guest from 54.167.10.244
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
.htaccess redirection to forums folder
p4kp4k




msg:4560386
 9:37 pm on Apr 1, 2013 (gmt 0)

Hi all,

Please help in setting up a .htaccess redirection which will:

-> redirect example.com to example.com/forum/ and
-> redirect example.com/any-posts.php to example.com/forum/any-posts.php

actually I created a forum a month ago but now need to redirect everything to /forum/ folder.

Thanks!

 

g1smd




msg:4560393
 10:08 pm on Apr 1, 2013 (gmt 0)

Let's see the code you have already tried.

p4kp4k




msg:4560396
 10:39 pm on Apr 1, 2013 (gmt 0)

Thanks g1smd for reply.

I can do this much:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ forum [L]


got it while searching the net.

It can accomplish half of what I need to do. i.e. the main url but not an internal url of the site.

phranque




msg:4560404
 10:52 pm on Apr 1, 2013 (gmt 0)

welcome to WebmasterWorld, p4kp4k!

it looks like you are trying to do an internal rewrite rather than a redirect.
in that case why are you looking at the hostname?

please describe what type of urls you want to link to in your documents and what the internal paths from the document root look like for those urls.
describe the urls requested and the responses you got for cases that worked as well as cases that failed.

lucy24




msg:4560420
 12:15 am on Apr 2, 2013 (gmt 0)

RewriteCond %{HTTP_HOST} ^(www.)?example.com$

This line is completely out of place here, though you'll use a similar line later on for your domain-name-canonicalization redirect. (Quick Forums search will turn up several hundred examples. The question is asked and answered at least once a week.)

Other than that, the only situation where you'd need to mention the HTTP_HOST is if you've got a single htaccess file serving multiple domains-- and frankly I would try very hard not to do that. At least where mod_rewrite is concerned.

:: uneasily wondering why Forums and/or browser breaks line after "domain-" even though there is plenty of room for "name-" as well ::

the main url but not an internal url of the site.

That's because you cribbed the code from a place using mod_alias (Redirect by that name). mod_alias reappends the rest of the path; mod_rewrite (even when functioning as a redirect) doesn't.

p4kp4k




msg:4560422
 12:25 am on Apr 2, 2013 (gmt 0)

Thanks for update.

I am not that advanced. Just need a re-write rule for mod_rewrite which will:

-> redirect example.com to example.com/forum/ and
-> redirect example.com/any-posts.php to example.com/forum/any-posts.php

phranque




msg:4560488
 6:22 am on Apr 2, 2013 (gmt 0)

from the Apache Web Server forum Charter - http://www.webmasterworld.com/apache/charter.htm [webmasterworld.com]:
It is not appropriate to expect other members to write your code for you or to debug your entire project; Please don't expect other members to solve a problem you don't want to begin solving yourself.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved