Welcome Guest, Not a member yet? Register   Sign In
Canonicalization with 301 redirection
#1

[eluser]earlyriser[/eluser]
I would like to apply a canonical domain to my site, without www.domain.com. I would like a redirection to domain.com.

This is my .htaccess file:

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301, L]

RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

The last 2 lines worked fine, the first lines are for the 301, but I got this error:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
More information about this error may be available in the server error log.

The error log was:
/home/calg/public_html/.htaccess: RewriteRule: bad flag delimiters

Do you have a hint?
#2

[eluser]earlyriser[/eluser]
I found the solution:

.htaccess
Code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Is there another way to do this without a htaccess file? Using the routes or config files?

Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB