Exclude a URL from rewrite in .htaccess with "last" flag
WordPress has been installed as a blog into osCommerce. I'm trying to get the WordPress RSS feed to work. All WP core files exist, but I get all kinds of errors accessing the feed at mydomain.com/wordpress/feed/, like 404s, "the feed can't be updated because the source file is no longer available," or even raw php code in the browser from the osCommerce feed file.
I think the problem is the rewrite rules for osCommerce, and I'm thinking if I can exclude the WP feed URL from rewrite, it will fix the feed or help find the real issue.
Looking around SO, I found a solution to use the "last" flag on a URL to prevent it from being rewritten. Problem开发者_运维技巧 is, the existing .htaccess already has a rule with a "last" flag on it.
Is there a way to not rewrite the WP feed URL? Can another "last" rule be added? I'd like to have some definite things to try before messing with .htaccess to avoid disrupting the site.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ http://www.mydomain.com/index.php?cPath=$1 [L]
RewriteRule ^(.*)-p-([0-9]+).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-([0-9]+).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-([0-9]+).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-([0-9]+).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-([0-9]+).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-([0-9]+).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-([0-9_]+).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-au-([0-9]+).html$ articles.php?authors_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-([0-9]+).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
# Information pages
RewriteRule ^(.*)-i-([0-9]+).html$ information.php?info_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-links-([0-9_]+).html$ links.php?lPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-n-([0-9]+).html$ newsdesk_info.php?newsdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nc-([0-9]+).html$ newsdesk_index.php?newsPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nri-([0-9]+).html$ newsdesk_reviews_info.php?newsdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nra-([0-9]+).html$ newsdesk_reviews_article.php?newsdesk_id=$2&%{QUERY_STRING}
I recommend to use two .htaccess files: one in your wordpress directory which catches all requests which should be handled by WordPress and one in your root directory for the rest.
I’m not so sure about the %{QUERY_STRING}
in your rewrite rules … test it thoroughly. Also, I don’t have any experience with Magento. The last time I tested it, it was way too slow. :)
As a start, here are the two .htaccess files:
/wordpress/.htaccess
RewriteEngine On
RewriteBase /wordpress/
# WordPress allows URLs like /2010/0/ or /00/ == doubled content
RewriteRule (^0+|(.*)/0+)/$ /$2 [L,R=301]
# WordPress: paged content creates a /page/
RewriteRule (^p|(.*)/p)age/(1/)?$ /$2 [L,R=301]
# Images, Stylesheets etc.
RewriteCond %{REQUEST_URI} !.+\.\w{2,4}$
# Existing file
RewriteCond %{REQUEST_FILENAME} !-f
# Existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# Symbolic link
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [L]
root /.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-p-([0-9]+).html$ product_info.php?products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-c-([0-9]+).html$ index.php?cPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-m-([0-9]+).html$ index.php?manufacturers_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pi-([0-9]+).html$ popup_image.php?pID=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pr-([0-9]+).html$ product_reviews.php?products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pri-([0-9]+).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-t-([0-9_]+).html$ articles.php?tPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-au-([0-9]+).html$ articles.php?authors_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-a-([0-9]+).html$ article_info.php?articles_id=$2&%{QUERY_STRING} [L]
# Information pages
RewriteRule ^(.*)-i-([0-9]+).html$ information.php?info_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-links-([0-9_]+).html$ links.php?lPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-n-([0-9]+).html$ newsdesk_info.php?newsdesk_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-nc-([0-9]+).html$ newsdesk_index.php?newsPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-nri-([0-9]+).html$ newsdesk_reviews_info.php?newsdesk_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-nra-([0-9]+).html$ newsdesk_reviews_article.php?newsdesk_id=$2&%{QUERY_STRING} [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (.*) /index.php?cPath=$1 [L]
Your web hoster has a very informative RewriteLog, which may help if you still have any problems.
精彩评论