Arun SS
Arun SS

Reputation: 1911

htaccess help needed

I want to redirect the http:mydomain.com to http//www.mydomain.com. Also I need to include one more condition

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

And I have redirect code as

RewriteCond %{HTTP_HOST} ^mydomain\.com 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,NC]

How to combine these two in a single htaccess file?

-Arun

Upvotes: 0

Views: 51

Answers (2)

noodl
noodl

Reputation: 17408

Litso's answer looks right to me but try this anyway..

RewriteEngine On    
RewriteCond %{HTTP_HOST} ^mydomain\.com 
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,NC]

RewriteCond %{REQUEST_URI} !^(index\.php|images|css|uploads|editor|albums|js|robots\.txt)
RewriteRule (.*) index.php/$1

I've replaced $! in the second condition and removed the redundant ^$ anchors from the rules.

Upvotes: 0

Stephan Muller
Stephan Muller

Reputation: 27630

Copy and paste them together in one .htaccess file should be enough. There's no reason those two are not able to be together in one .htaccess. You should have the www one run first though:

RewriteEngine On    
RewriteCond %{HTTP_HOST} ^mydomain\.com 
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,NC]

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

Upvotes: 1

Related Questions