Help With Redirecting Using htaccess File!

  • Steve[D]
  • Newbie
  • Newbie
  • Steve[D]
  • Posts: 6

Post 3+ Months Ago

Hi,

I currently have four links to my forum as listed below:

Code: [ Select ]
http://mysite .com/forum/
http://mysite .com/forum/index.php
http://www.mysite .com/forum/
http://www.mysite .com/forum/index.php
  1. http://mysite .com/forum/
  2. http://mysite .com/forum/index.php
  3. http://www.mysite .com/forum/
  4. http://www.mysite .com/forum/index.php



Ive heard that Google can mistake these for 4 different websites which can lead to split results and poor ranking. So how can I edit my .htaccess file so that each of the above redirects to just one;

Code: [ Select ]
http://www.mysite .com/forum/



Im using vbulletin, if that makes any difference.

Many Thanks,
Steve. :D
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida
  • Steve[D]
  • Newbie
  • Newbie
  • Steve[D]
  • Posts: 6

Post 3+ Months Ago

Hi,

Thanks for the quick reply. I have something similar as to what is suggested in that thread.

Unfortuately, there seems to be a conflict between the .htaccess file in the root directory (mysite .com/) which contains the following:

Code: [ Select ]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteCond %{HTTPS} =on
RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} ^mysite\.com
RewriteCond %{HTTPS} !=on
RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.mysite .com/$1 [R=301,L]
  1. RewriteEngine on
  2. RewriteCond %{HTTP_HOST} ^mysite\.com
  3. RewriteCond %{HTTPS} =on
  4. RewriteRule .* https://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
  5. RewriteCond %{HTTP_HOST} ^mysite\.com
  6. RewriteCond %{HTTPS} !=on
  7. RewriteRule .* http://www.%{SERVER_NAME}%{REQUEST_URI} [R,L]
  8. RewriteCond %{THE_REQUEST} ^.*/index.html
  9. RewriteRule ^(.*)index.html$ http://www.mysite .com/$1 [R=301,L]




And the one in the forum subdirectory (mysite .com/forum/) which contains the following - required by an add on Im using:

Code: [ Select ]
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-z0-9_\-]*-(f|all)[0-9]+(p[0-9]+|/index[0-9]*)?\.html)$ forumdisplay.php/$1 [QSA,L]
RewriteRule ^([a-z0-9_\-]*-(t|p)[0-9]+(p[0-9]+|/index[0-9]*)?\.html)$ showthread.php/$1 [QSA,L]
RewriteCond %{REQUEST_URI} !(index\.php|\.css) [NC]
RewriteRule ^(archive|sitemap)/(.*)$ $1/index.php/$2 [QSA,L]
  1. Options +FollowSymlinks
  2. RewriteEngine on
  3. RewriteRule ^([a-z0-9_\-]*-(f|all)[0-9]+(p[0-9]+|/index[0-9]*)?\.html)$ forumdisplay.php/$1 [QSA,L]
  4. RewriteRule ^([a-z0-9_\-]*-(t|p)[0-9]+(p[0-9]+|/index[0-9]*)?\.html)$ showthread.php/$1 [QSA,L]
  5. RewriteCond %{REQUEST_URI} !(index\.php|\.css) [NC]
  6. RewriteRule ^(archive|sitemap)/(.*)$ $1/index.php/$2 [QSA,L]



Since when I remove the latter the force www. does work!

Can anyone spot the problem?
Thanks! :)
  • Steve[D]
  • Newbie
  • Newbie
  • Steve[D]
  • Posts: 6

Post 3+ Months Ago

UPDATE:

Ok, In the end I removed the htaccess file from the forum subdirectory as I found another way to achieve the same thing.


Im wondering if I could also use the htaccess file to redirect from;


http://www.mysite .com/forums

to

http://www.mysite .com/forum


Should visitors accidentally misspell the URL.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

I'm reluctant to suggest this because you mentioned that you "found another way", but haven't mentioned what that is, but here's the rewrite assuming I'm working from square one.

APACHE Code: [ Select ]
RewriteEngine On
RewriteBase /
 
RewriteRule ^forums(/.*)?$ forum$1 [R=301]
  1. RewriteEngine On
  2. RewriteBase /
  3.  
  4. RewriteRule ^forums(/.*)?$ forum$1 [R=301]

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 86 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.