Forum Moderators: phranque

Message Too Old, No Replies

Short URL mod re-write won't allow access to forum

Short URL mod re-write rules and conditions won't allow access to forum.

         

Tim_Sitzer

2:52 pm on May 19, 2006 (gmt 0)



Hi everyone,

I am new to Webmaster World and am in need of a little help. I have very little experience with mod re-write other than what I have Googled.

My website is built around Miva Merchant 5 and all pages are dynamic. I am using the following to create static looking URLS:

DirectoryIndex index.html /mm5/merchant.mvc?

Options +FollowSymlinks
RewriteEngine On
#

RewriteCond %{REQUEST_URI} ^/p/(.*)/(.*)[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=PROD&Product_Code=%1&Store_Code=UTP [L]
RewriteCond %{REQUEST_URI} ^/products/(.*)/(.*)/(.*)[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=PROD&Product_Code=%1&Category_Code=%2&Store_Code=UTP [L]
RewriteCond %{REQUEST_URI} ^/category/(.*)/(.*)[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=CTGY&Category_Code=%1&Store_Code=UTP [L]
RewriteCond %{REQUEST_URI} ^/page/(.*).html[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=%1 [L]

All of my links are relative and I use a base href statement. For the most part, 99% of my dynamic URLS are being displayed as static looking links with no problems.

The problem I have is that my forum folder is no longer accessible. My relative link is /forum/ . When I hover over the link, it shows I should go to my forum folder. But when I follow the link, I am redirected to my home page.

I have been trying to Google a fix to exclude this folder from the above rules, but I do not have enough knowledge of mod re-write to know what I am looking for.

Any ideas?

jdMorgan

7:43 pm on May 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I assume that your forum URL matches the pattern in one or more of your rules, and so is being rewritten to your merchant.mvc script. The script doesn't recognize it as a legitimate cat/prod request, and therefore redirects it to the home page as a catch-all.

You could:

Add an additional RewriteCond to each rule that could match the forum URLs to exclude the forum URLs from being rewritten.


RewriteCond %{REQUEST_URI} !^/URL_path_to_forum

Add a rule at the top to exit mod_rewrite immediately, skipping all of the remaining rules, if a forum URL is requested.

RewriteRule ^URL_path_to_forum - [L]

Add a rule at the top to skip a specified number of rules (the miva rewriterules), if a forum URL is requested.

RewriteRule ^URL_path_to_forum - [S=4]

The rules you have now are implemented in a fairly inefficient manner and could be improved, as discussed here [webmasterworld.com].

For background information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim