rewrite rule clashing - html to php with phpbb-seo rewrite

Discussions about Apache mod Rewrite, .htaccess, Use, experiences ... URL Rewriting.

Moderator: Moderators

rewrite rule clashing - html to php with phpbb-seo rewrite

Postby panexp » Thu Dec 28, 2006 5:33 pm

Hello!

I have been using the mixed mod-rewrite without any problems, but I am wanting to run a new rewrite rule for my main site files that rewrites .html to .php in the urls. (in other words, a link to page.html is actually page.php) I have it working just fine, but the rule causes a 404 when you try to view a topic in the forum. I think (??) it is caused by my new rule.

So, how can I write this rule so that it ignores anything in the /forum/ directory? (or am I going about this backwards?)

Here's a snippet of the .htaccess in my site root. My phpbb is located in /forums/:

RewriteEngine On
#add the www always
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]
#rewrite .html to .php
RewriteRule ^(.*).html$ $1.php

#phpBB SEO Mod addition
RewriteBase /
###########skip the credits......
# FORUM PROTECTION RULE
RewriteRule ^forums/.+/([^/]+\.html)$ /forums/index.php [R=301,L]
# CATEGORIES
RewriteRule ^forums/.+-vc([0-9]+)\.html$ /forums/index.php?c=$1 [QSA,L]
......etc....etc....etc...etc The rest is stock mixed mod_rewrite

So, can I tell my rule to fix everything EXCEPT the /forum/ or is there a better fix?
panexp
 
Posts: 4
Joined: Mon Oct 02, 2006 12:26 am

Advertisement

Postby panexp » Thu Dec 28, 2006 6:40 pm

Well, I managed to answer my own question! Maybe this will help someone else:

Just add a RewriteCond to the rule:

RewriteCond %{REQUEST_URI} !^.*forums.*$
RewriteRule ^(.*).html$ $1.php

If any knows a better way to do this let me know!!
panexp
 
Posts: 4
Joined: Mon Oct 02, 2006 12:26 am

Postby dcz » Thu Dec 28, 2006 11:08 pm

A simpler and faster way :

Code: Select all
RewriteRule ^([^forums/].+)\.html$ $1.php [L]


;)

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21238
Joined: Fri Apr 28, 2006 9:03 pm


Return to Apache mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 4 guests