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

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

Apache Web Server Forum

    
Possibly Redunant or Misguided htaccess rewrites
citizenKayne



 
Msg#: 4624894 posted 8:31 pm on Nov 20, 2013 (gmt 0)

Hello,

To make a long story short, I have a website running off of magento in a 1st level sub-folder. Its a relatively small website with about 65 products and probably a total of around 300 pages which is including dynamic pages as well. I have an extension installed that helps me put canonical tags and NOINDEX,FOLLOW tags on a majority of pages like reviews, wishlist, etc.. However, GWT is currently indexing over 900 pages which an extra 50 appeared a couple of days ago.

I think my .htaccess is setup incorrectly because this "/magento/index.php" and "/magento/" are showing up in some of the Internal Links and HTML Improvements content displayed in GWT.

Here's some of the rewrite section of my .htaccess in my root folder.


Options +FollowSymLinks
RewriteEngine on

RewriteBase /magento


############################################
## always send 404 on missing files in these folders

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

RewriteRule .* index.php [L]
RewriteRule ^$ /magento/ [QSA,L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !^(magento|subdirN)(/.*)?$ /magento%{REQUEST_URI} [QSA,L]


Would the .htaccess in the magento installation folder be affecting this as well, or is it primarily the one in the root folder?

Thanks in advance for any assistance/direction.

 

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4624894 posted 10:36 pm on Nov 20, 2013 (gmt 0)

Would the .htaccess in the magento installation folder

Do you have more than one htaccess file, both containing RewriteRules? Consolidate them all into one file. It is technically possible to have RewriteRules in more than one place along the same path, but you should go to great lengths to avoid it.

:: insert "Do as I say, not as I do" boilerplate ::

Also:
All that #commenting is good. But you MUST place your blank lines appropriately. DO put a blank line after each RewriteRule. DON'T put blank lines after a RewriteCond. This is for your own information; it doesn't affect the working of the rules. Blank lines don't have syntactic meaning, but you need to be able to tell at a glance where one ruleset stops and another begins.

Another thing you should go to great lengths to avoid is multiple -f or -d lookups for the same request. Even one is rarely necessary or appropriate.

citizenKayne



 
Msg#: 4624894 posted 11:00 pm on Nov 20, 2013 (gmt 0)

Thanks for replying lucy24. This is the .htaccess that's in the sub-folder which is my magento installation folder:

############################################
## always send 404 on missing files in these folders

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/

############################################
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

############################################
## rewrite everything else to index.php

RewriteRule .* index.php [L]


As you can see its practically the same as whats in the root, minus the '/magento" rewrites. It's the standard one that comes with a Magento installation so I left it as is. However since you mentioned that its possible to have rewriting done twice due to multiple .htaccess files, I'm wondering if this one is causing some of it?

And thanks for the other advice as well. With my root .htaccess, I see where I'm kind of saying the same thing twice. Once with the 3 conditions followed by 2 rewrites, then 2 conditions followed by 1 rewrite. Is that correct?

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