Welcome Guest, Not a member yet? Register   Sign In
help with htaccess
#1

[eluser]Unknown[/eluser]
Hello,

I'm not too good with the apache Rewrite engine, i would need a little help with it, I would need a htaccess that redirects the www to none www like http://www.domain.com to http://domain.com also if the request is the / (http://domain.com/) it redirects it to /main/index (http://domain.com/main/index) but if the request is anything other than / it leaves it as it is...

If someone can help me with this I would really apreciate it...

Thanks and Regards
#2

[eluser]m4rw3r[/eluser]
You want to have /main/index as the default controller(/method)?
If so, change the default_controller in config/routes.php
Example:
Code:
$route['default_controller'] = "main";
will redirect all calls to / to the main controller's index method (or another if you use _remap).

Dunno about the removal of www. , may I ask why you need it?
#3

[eluser]Unknown[/eluser]
the none-www is a SEO think, i dont whant multiple URL for the site...
i know how to set the default controller and the default function for it, but i need that all the requests to the web root / to be redirected to /main/index with a 301 header
#4

[eluser]Pascal Kriete[/eluser]
To remove the www:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

To redirect to /main/index from / only:
Code:
RewriteRule ^/ /main/index [R=301,L]

Put them in that order so that the www is removed first.




Theme © iAndrew 2016 - Forum software by © MyBB