Forum Moderators: phranque

Message Too Old, No Replies

wordpress and oscommerce htaccess problem

         

security man

9:29 am on Jan 13, 2012 (gmt 0)

10+ Year Member



i have a domain with wordpress and oscommerce installations on it. wordpress is in the root, oscommerce is in the /store/ dir off the root. the site works fine and displays properly in both wordpress and oscommerce. however in oscommerce the server headers are throwing 404 errors even though the page is displaying properly. this means that googlebot is not indexing these pages at all and that is a major issue. any help on this would be greatly appreciated.


the site is [outdoorwatersolutions.com...]


the root htaccess is:



RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html

RewriteEngine On
RewriteCond %{HTTP_HOST} ^outdoorwatersolutions.com [NC]
RewriteRule ^(.*)$ http://www.outdoorwatersolutions.com/$1 [L,R=301]


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>



and the oscommerce htaccess is:


Options +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
RewriteEngine On

# RewriteBase instructions
# Change RewriteBase dependent on how your shop is accessed as below.
# http://www.mysite.com = RewriteBase /
# http://www.mysite.com/catalog/ = RewriteBase /catalog/
# http://www.mysite.com/catalog/shop/ = RewriteBase /catalog/shop/

# Change RewriteBase using the instructions above
RewriteBase /store/
RewriteRule ^([a-z0-9/-]+)-p-([0-9]+).html$ product_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-c-([0-9_]+).html$ index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-m-([0-9]+).html$ index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-pi-([0-9]+).html$ popup_image.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-pr-([0-9]+).html$ product_reviews.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-pri-([0-9]+).html$ product_reviews_info.php [NC,L,QSA]
# Articles contribution
RewriteRule ^([a-z0-9/-]+)-t-([0-9_]+).html$ articles.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-au-([0-9]+).html$ articles.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-a-([0-9]+).html$ article_info.php [NC,L,QSA]
# Information pages
RewriteRule ^([a-z0-9/-]+)-i-([0-9]+).html$ information.php [NC,L,QSA]
# Links contribution
RewriteRule ^([a-z0-9/-]+)-links-([0-9_]+).html$ links.php [NC,L,QSA]
# Newsdesk contribution
RewriteRule ^([a-z0-9/-]+)-n-([0-9]+).html$ newsdesk_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-nc-([0-9]+).html$ newsdesk_index.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-nri-([0-9]+).html$ newsdesk_reviews_info.php [NC,L,QSA]
RewriteRule ^([a-z0-9/-]+)-nra-([0-9]+).html$ newsdesk_reviews_article.php [NC,L,QSA]
</IfModule>

g1smd

8:27 pm on Jan 13, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You should combine both rulesets into the root htaccess.

All of your rules should use RewriteRules.

Redirects should be listed before rewrites.

The oscommerce rules should be the first of the rewrites (as they are more specific) and each RegEx pattern should be prefixed with the oscommerce folder name.

The general wordpress rewrite ruleset should be last.

security man

8:47 pm on Jan 13, 2012 (gmt 0)

10+ Year Member



thanks manno - so to make sure i understand... the two rewritebase lines are what cause the two to not be able to be combined just as they are, is that correct? I ask because i tried simply pasting the oscommerce rules above the wordpress rules in the root htaccess and it caused all kinds of problems.

this would be correct? or should the ^ go before the /store/? Sorry for not knowing this kinda stuff, i appreciate your patience


RewriteRule /store/^([a-z0-9/-]+)-p-([0-9]+).html$ product_info.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-c-([0-9_]+).html$ index.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-m-([0-9]+).html$ index.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-pi-([0-9]+).html$ popup_image.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-pr-([0-9]+).html$ product_reviews.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-pri-([0-9]+).html$ product_reviews_info.php [NC,L,QSA]
# Articles contribution
RewriteRule /store/^([a-z0-9/-]+)-t-([0-9_]+).html$ articles.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-au-([0-9]+).html$ articles.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-a-([0-9]+).html$ article_info.php [NC,L,QSA]
# Information pages
RewriteRule /store/^([a-z0-9/-]+)-i-([0-9]+).html$ information.php [NC,L,QSA]
# Links contribution
RewriteRule /store/^([a-z0-9/-]+)-links-([0-9_]+).html$ links.php [NC,L,QSA]
# Newsdesk contribution
RewriteRule /store/^([a-z0-9/-]+)-n-([0-9]+).html$ newsdesk_info.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-nc-([0-9]+).html$ newsdesk_index.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-nri-([0-9]+).html$ newsdesk_reviews_info.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-nra-([0-9]+).html$ newsdesk_reviews_article.php [NC,L,QSA]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

security man

11:56 pm on Jan 14, 2012 (gmt 0)

10+ Year Member



well i tried it both with the /store/ before and after the ^ with no avail... this is what i tried:


RewriteRule /store/^([a-z0-9/-]+)-p-([0-9]+).html$ product_info.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-c-([0-9_]+).html$ index.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-m-([0-9]+).html$ index.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-pi-([0-9]+).html$ popup_image.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-pr-([0-9]+).html$ product_reviews.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-pri-([0-9]+).html$ product_reviews_info.php [NC,L,QSA]
# Articles contribution
RewriteRule /store/^([a-z0-9/-]+)-t-([0-9_]+).html$ articles.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-au-([0-9]+).html$ articles.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-a-([0-9]+).html$ article_info.php [NC,L,QSA]
# Information pages
RewriteRule /store/^([a-z0-9/-]+)-i-([0-9]+).html$ information.php [NC,L,QSA]
# Links contribution
RewriteRule /store/^([a-z0-9/-]+)-links-([0-9_]+).html$ links.php [NC,L,QSA]
# Newsdesk contribution
RewriteRule /store/^([a-z0-9/-]+)-n-([0-9]+).html$ newsdesk_info.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-nc-([0-9]+).html$ newsdesk_index.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-nri-([0-9]+).html$ newsdesk_reviews_info.php [NC,L,QSA]
RewriteRule /store/^([a-z0-9/-]+)-nra-([0-9]+).html$ newsdesk_reviews_article.php [NC,L,QSA]


RewriteRule ^/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

g1smd

12:15 am on Jan 15, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Escape literal periods in each RegEx pattern.

Pattern should begin ^store/([a-z

This code cannot be guessed. You need to spend some time reading both a good Regular Expressions tutorial and the Mod_Rewrite section of the Apache manual.

security man

10:06 pm on Jan 15, 2012 (gmt 0)

10+ Year Member



still no love. i have read as many places as i can to figure this out. regular expressions are just very tough for me to understand and you seem to be the only one i have found that can tell me what is going on. i am really not wanting you to do it for me or anything, its difficult when there is no feedback from the server as to where the issue may be at.

this is what i tried this time with no luck

RewriteRule ^store/([a-z0-9/-]+)-p-([0-9]+)\.html$ product_info.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-c-([0-9_]+)\.html$ index.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-m-([0-9]+)\.html$ index.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-pi-([0-9]+)\.html$ popup_image.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-pr-([0-9]+)\.html$ product_reviews.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-pri-([0-9]+)\.html$ product_reviews_info.php [NC,L,QSA]
# Articles contribution
RewriteRule ^store/([a-z0-9/-]+)-t-([0-9_]+)\.html$ articles.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-au-([0-9]+)\.html$ articles.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-a-([0-9]+)\.html$ article_info.php [NC,L,QSA]
# Information pages
RewriteRule ^store/([a-z0-9/-]+)-i-([0-9]+)\.html$ information.php [NC,L,QSA]
# Links contribution
RewriteRule ^store/([a-z0-9/-]+)-links-([0-9_]+)\.html$ links.php [NC,L,QSA]
# Newsdesk contribution
RewriteRule ^store/([a-z0-9/-]+)-n-([0-9]+)\.html$ newsdesk_info.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-nc-([0-9]+)\.html$ newsdesk_index.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-nri-([0-9]+)\.html$ newsdesk_reviews_info.php [NC,L,QSA]
RewriteRule ^store/([a-z0-9/-]+)-nra-([0-9]+)\.html$ newsdesk_reviews_article.php [NC,L,QSA]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

g1smd

10:12 pm on Jan 15, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




To figure this out, you need to make sure that your links point to the correct URLs, then ensure that your RewriteRules capture the right requests and then pull the correct matching content from inside the filesystem.

What does the Live HTTP Headers extension for Firefox report?

security man

11:03 pm on Jan 15, 2012 (gmt 0)

10+ Year Member



okay, so i am a moron, i need to add /store/ to all the links after the regex - did that but still not working, well the page shows up now but the headers still show 404... i am at a total loss. the report from live http headers is:


http://www.outdoorwatersolutions.com/store/bacteria-pack-pail-p-90.html

GET /store/bacteria-pack-pail-p-90.html HTTP/1.1
Host: www.outdoorwatersolutions.com
User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
Cookie: osCsid=5bf587dcafa6840ea56d5574f467af3e; __utma=7483948.27979324.1326668183.1326668183.1326668183.1; __utmb=7483948.4.10.1326668183; __utmc=7483948; __utmz=7483948.1326668183.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Cache-Control: max-age=0

HTTP/1.1 404 Not Found
Date: Sun, 15 Jan 2012 22:59:54 GMT
Server: Apache/2
X-Powered-By: PHP/5.2.17
X-Pingback: http://www.outdoorwatersolutions.com/xmlrpc.php
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Last-Modified: Sun, 15 Jan 2012 22:59:54 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 7301
Keep-Alive: timeout=10, max=99
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

security man

1:56 pm on Jan 17, 2012 (gmt 0)

10+ Year Member



hey g1smd, i tried to send you a private message, but your box was full. can you contact me directly? i would like to hire you to get this fixed once and for all.

phranque

1:43 pm on Jan 18, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



try turning on the rewrite log if possible and you might figure out what is happening there.