Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine on
RewriteRule mysite.com [mysite.com...] [R=301,L]
will redirect to the site, but wont change the url to www.mysite.com
thanks for all your help
Welcome to WebmasterWorld [webmasterworld.com]!
This is probably what you need:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
Jim
Thanks for the reply. Unfortunately, I did as suggested and again the redirect works yet
the url does not get rewritten.
Oddly enough even without the .htaccess file, when someone types in mysite.com, they do get redirected to www.mysite.com.
Could there perhaps be a hiddden .htaccess file on the server, or something that the web hosting has in place that perhaps over writes this!
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI}!-s
RewriteRule ^page/(.*) /Merchant2/merchant.mvc?page=$1
RewriteCond %{HTTP_HOST} myorgsite\.org$ [NC]
RewriteCond %{REQUEST_URI}!^/myorgsite [NC]
RewriteRule ^(.*)$ /myorgsite%{REQUEST_URI} [L]
I noticed that Google index 96 pages a few weeks ago, and has come back since the second Rewrite was put in and only looked at one page. Could there be something wrong here? Do I need another way to use this rewrite? Also, I don't want Google to know that mysiteorg is part of mysite. Will it be able to realize that from this file?
I actually have several domains that are using the rewrite in this file, and I don't want them to show as connected to one another.
Thanks much for any input on this.
Introduction to mod_rewrite [webmasterworld.com]
Since your post is not directly-related to jade233's question, it really should be in a separate thread. But I don't see anything wrong with your code. Since you use internal redirects, search engines will be unaware of any rewrites. The only thing I saw was that your second rule could be either
RewriteRule ^(.*)$ /myorgsite/$1 [L]
- or -
RewriteRule .* /myorgsite%{REQUEST_URI} [L]
If you have any doubts about your rewrites, test them using a browser and also using the server headers checker [webmasterworld.com] to make sure your server status response is correct - In your case, you expect a 200-OK and not a 301 or 302.
Jim
[edited by: jdMorgan at 8:01 pm (utc) on Jan. 12, 2004]
It's possible that your host has given you two top-level directories, one for each of your domain-name variants. So code inserted into your www-domain top-level directory may not affect requests that come through your non-www-domain directory. Look around using ftp or telnet, and see if you have two top-level directories.
Another possibility is that mod_rewrite is not supported by your host. In cases like yours, I suggest doing a simple test: Redirect from a URL that does not exist to one that you know exists, and check the results using your browser:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^nonexistent_file\.html$ /known_to_exist_file.html [R=310,L]
Jim