homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Canonical redirect issue

 3:45 pm on Oct 23, 2013 (gmt 0)

I understand that with Google, you need to get the canonical redirect working correctly, else you might lose PR.

When you go to my homepage, if you type mysite.com, it goes to www.mysite.com. But if you go to mysite.com/forums/, it stays there, rather than redirecting to www.mysite.com/forums/.

How can I get it to go to www.mysite.com/forums/ ?

My htaccess code is:

# Externally redirect only direct client requests for /index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index.(html?|php)\ HTTP/
RewriteRule ^(([^/]+/)*)index.(html?|php)$ http://www.example.co.uk/$1 [R=301,L]
# Externally redirect to canonicalize the domain name if a non-canonical
# hostname is requested, in order to prevent duplicate-content problems
RewriteCond %{HTTP_HOST} !^(www\.example\.co.uk)?$
RewriteRule (.*) http://www.example.co.uk/$1 [R=301,L]

[edited by: aakk9999 at 3:56 pm (utc) on Oct 23, 2013]
[edit reason] Examplified domain in .htaccess code [/edit]



 5:01 pm on Oct 23, 2013 (gmt 0)

When placed in the root htaccess file, that code should do what you want.

Check to see if there is another htacess file in the /forums/ folder. That may be the problem.

There's three places where a literal period needs to be escaped.


 8:22 am on Oct 24, 2013 (gmt 0)

I just checked and there is an htaccess file in the forums folder. Here it is:

AcceptPathInfo On

RewriteEngine On
RewriteRule ^((urllist|sitemap).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]

xcache.var_size = 3M
xcache.var_count = 2
xcache.var_slots = 8K
xcache.var_ttl = 7200
xcache.var_maxttl = 14400
xcache.var_gc_interval = 300

What should I do?


 12:50 pm on Oct 24, 2013 (gmt 0)

Move all that stuff to the root htaccess file.

Adjust the Regex pattern to match the requested URLs and the rule target for the actual script location.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved