FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Help needed with mod rewrite





kv
I need to create a htaccess with mod rewrite directives. It should satisfy the following conditions.

mydomain.com and www.mydomain.com => redirected to www.mydomain.com/forum

www.mydomain.com/forum/* => no action, use as is

any thing other than the above => redirect to a custom error page (www.mydomain.com/errorpage.php)

I am not very good at mod rewrite. Please help me with the above task.
alalex
all right, so you want to redirect visitors in root level to /forums, but there is no need for you to use mod_rewrite, you could just use a normal 301 redirection in the .htaccess:
Code:
Redirect 301 / http://mydomain.com/forum


And that should be it Wink
kv
Ok. That is great. But I also need to redirect anything other than / and /forum(.*) to an error page. How can I do that?
alalex
Well, if you mean any other folder, you could place another .htaccess in every folder level you want to redirect to somewhere else, like an error page.
If you mean to redirect in 404 case for example, just add this:
Code:
ErrorDocument 401 /errorpages/authorization.php
ErrorDocument 404 /errorpages/notfound.php
ErrorDocument 500 /errorpages/internalerror.php

But i am not sure about what you are asking...

If I understood correctly, you want your users to be redirected to the forum whatever they enter right?
Then I am guessing that you could have the 301 redirection, and then add the errorDocument with a redirection to the forum, so that in case they enter a non-valid page, they'll go to the forum index...
Hope that helps! Wink
kv
I will explain the scenario.

I am developing a website for my client who has hosting with some hosting company, which has a default error handler -- on 404, browser is redirected to some standard error page. They don't offer custom error pages and ErrorDocument in .htaccess does not work (mod rewrite is supported though). My client does not want to show the standard error page if visitors make a mistake in the url.

The only way I think is to make all URLs other than http://mydomain.com/forum(.*) to be redirected to some custom error page using mod rewrite.
Stubru Freak
kv wrote:
I will explain the scenario.

I am developing a website for my client who has hosting with some hosting company, which has a default error handler -- on 404, browser is redirected to some standard error page. They don't offer custom error pages and ErrorDocument in .htaccess does not work (mod rewrite is supported though). My client does not want to show the standard error page if visitors make a mistake in the url.

The only way I think is to make all URLs other than http://mydomain.com/forum(.*) to be redirected to some custom error page using mod rewrite.


Code:
RewriteCond %{REQUEST_URI} !^/forum
RewriteCond %{REQUEST_URI} !^/yourerrorpage
RewriteRule .* /yourerrorpage
kv
Thanks a lot
Related topics
Help Needed Regarding CGI And Php
Help needed to choose appropriate server.
Mod Rewrite!!
Clan NDA HELP NEEDED FOR WEBSITE
help with mod_rewrite
How to use mod rewrite?
Does mod rewrite nescessary?
Appache Mod Rewrite
mod rewrite - danger?
Big Help needed .
Help Needed - URL format
Need help with file permissions for WordPress & plugins
Mod rewrite subdomain
No icons on backend??
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.