g1smd

msg:4337181 | 10:08 pm on Jul 8, 2011 (gmt 0) |
For non-www/www redirect use this pattern: !^(www\.example\.com)?$ instead. Use example.com here to stop forum auto-linking | I want to get rid of everything after the / that is dynamically created. |
| After the slash or after the question mark? Slash would be removing "path" elements. Question mark would be "query string".
|
underglass

msg:4337201 | 10:42 pm on Jul 8, 2011 (gmt 0) |
| For non-www/www redirect use this pattern: !^(www\.example\.com)?$ instead. |
| Thank you! Will try and let you know. | After the slash or after the question mark? Slash would be removing "path" elements. Question mark would be "query string". |
| The query string - the question mark and everything after. I want to keep the path.
|
g1smd

msg:4337225 | 11:08 pm on Jul 8, 2011 (gmt 0) |
A question mark on the end of the target removes any and all parameters. You'll need a RewriteCond testing QUERY_STRING or THE_REQUEST to make sure the original request did have an appended query string. To be clear, if you accidentally redirect "without query string" to "without query string", you will end up with an infinite redirect loop.
|
underglass

msg:4337255 | 12:31 am on Jul 9, 2011 (gmt 0) |
I may be completely misunderstanding you, but will this do both the non-www/www redirect, remove any and all parameters, and not create an infinite redirect loop? (the +++ are mine - do not want to create a false link) RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ RewriteRule (.*) +h+t+t+p://www.example.com/$1 [R=301,L] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress This is all I have in my .htaccess file. I really have zero experience with this. Zip. Nada.
|
g1smd

msg:4337257 | 12:35 am on Jul 9, 2011 (gmt 0) |
You need to read a few tutorials on mod_rewrite and on Regular Expressions. The existing rule redirects any hostname request that is not exactly "www.example.com" to "www.example.com". The page detail is unchanged by the redirect. You need additional code, maybe even additional rules, to cater for the other things as described above.
|
underglass

msg:4337263 | 12:45 am on Jul 9, 2011 (gmt 0) |
I will read a few tutorials. I made none of the suggested changes to my .htaccess file. I have had the same one in place for many months and does not seem to be causing any major problems with ranking or my site. Thank you just the same!
|
lucy24

msg:4337274 | 2:09 am on Jul 9, 2011 (gmt 0) |
| will this do both the non-www/www redirect, remove any and all parameters, and not create an infinite redirect loop? (the +++ are mine - do not want to create a false link) |
| Heheh, that's the whole point of example.com. The Forums are especially coded so http://www.example.com will never turn into a link: http://www.example.com http://www.example.com/ http://www.example.com/index.html http://www.example.com/index.php http://www.example.com/folder1/folder2/folder3/filename.html Wasn't that fun? | You'll need a RewriteCond testing QUERY_STRING or THE_REQUEST to make sure the original request did have an appended query string. To be clear, if you accidentally redirect "without query string" to "without query string", you will end up with an infinite redirect loop. |
| That is: At every point, you need to make sure the rules only apply to patterns that have not already had this Rewrite done to them. (That is what makes [N] so dangerous. You have to make sure that eventually there will be nothing left to rewrite.) In your case, there are two things: !^(www\.example\.com)?$ means apply the following rule to any request that doesn't use either the exact name "www.example.com" or nothing at all. %{QUERY_STRING} \S means apply the following rule only to requests that currently have a query string. \S means a non-space of any kind, un-anchored. You might even get away with . meaning "anything whatsoever" but that looks a bit too minimalist. If your Mystery Code is appending spurious queries that consist entirely of spaces, I don't want to hear about it.
|
g1smd

msg:4337312 | 6:44 am on Jul 9, 2011 (gmt 0) |
Yes, this is what you need:
{QUERY_STRING} . The " . " is important.
|
underglass

msg:4337384 | 2:09 pm on Jul 9, 2011 (gmt 0) |
http://www.example.com http://www.example.com/ http://www.example.com/index.html http://www.example.com/index.php http://www.example.com/folder1/folder2/folder3/filename.html Wasn't that fun? |
| Yes, that is fun...and thank you! After reading some tutorials, I think what you both wrote will make sense. Or at least I hope so. I "get" what you are saying, but do not yet know how to write it without causing some problems. Right now I think the quickest way to solve my issue is to use the <link rel="canonical" href="http://www.example.com/"/> and my WP redirection plugin when necessary. Thank you both for your help.
|
|