Hello, I'm unable to move the following commands from .htaccess to httpd.config without causing weird problems; RewriteEngine On RewriteCond %{HTTP_HOST} ^mysitename\.com RewriteCond %{SERVER_PORT} ^80$ RewriteRule (.*) http://www.mysitename.com/$1 [R=301,L,QSA] Must the above commands be altered somehow to work in httpd.config? I really want to eliminate the .htaccess file so the server does not have to check before each page load. If somebody could show me the proper commands, it would help so much. Thank you
First, tell us what the actual error(s) is/are when you move this to a .conf file, also check your apache error logs and turn on RewriteLog so you can see verbosely where you might have gone wrong, thanks.
Thanks for replying. Redirects wouldn't work; a) 301's failed to execute when clicking banners b) And failed to redirect properly when typing in non-www versions of url's
Those directives look fine to me which indicates that it must be something else outside these lines that is causing it not to work. Two things I can see from what you have pasted: 1. If someone hits your site using anything other than sitename.com, they won't be redirected. 2. If your website is only listening on another port, they won't be redirected. If you are using NameVirtualHost and you have other domains on the same server, make sure you have a ServerAlias directive of sitename.com as well as a ServerName of www.sitename.com. Also, make sure these directives (both the ServerAlias and the RewriteRules) are in the VirtualHost container. You can change this line: RewriteCond %{HTTP_HOST} ^mysitename\.com Code (markup): to this: RewriteCond %{HTTP_HOST} !^www\.mysitename\.com Code (markup): which is useful if this vhost is the default vhost. You can drop the %{SERVER_PORT} line entirely unless there are people hitting your website on another port that you don't want redirected. I noticed that you are using [L] in your rewrite. If you have another rewrite above that one that matches normal queries, has an [L] and doesn't have a [R] or [R=301] then it will never get to the lines you have given us.