Forum Moderators: phranque

Message Too Old, No Replies

need help fixing .htaccess error

new Mod_rewrite rule causes conflict & .htaccess error

         

richards1052

9:19 am on Jun 25, 2005 (gmt 0)

10+ Year Member



I have mod_rewrite rules in my .htaccess file which convert permalinks from my old Typepad blog to WP permalinks.

The other day, someone helped me add similar rewrite rules to allow images originally uploaded to Typepad to display properly in WP. The images are now displaying fine.

But in looking over my site stats tonight, I see hits from my old format permalinks. This means that the permalink conversion rewrite rules are no longer working & people using old links are getting "post not found" error msgs. when they're brought to my new blog site.

Sure enough, when I looked over my .htaccess file I saw this error:

# File modified on Thu Jun 23 15:26:28 2005 by server
# \xef\xbb\xbf# is not a supported htaccess directive
# # File modified on Thu Jun 23 15:15:28 2005 by server
# \xef\xbb\xbf# is not a supported htaccess directive

Pls. someone tell me if there's an obvious mistake to be corrected.


RewriteEngine On
RewriteBase /tikun_olam/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=50]
RewriteRule ^(about-me)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(about-me)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(about-me)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?pagename=$1&paged=$2 [QSA,L]
RewriteRule ^(about-me)(/[0-9]+)?/?$ /tikun_olam/index.php?pagename=$1&page=$2 [QSA,L]
RewriteRule ^(about-me)/trackback/?$ /tikun_olam/index.php?pagename=$1&tb=1 [QSA,L]
RewriteRule ^(contact)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(contact)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(contact)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?pagename=$1&paged=$2 [QSA,L]
RewriteRule ^(contact)(/[0-9]+)?/?$ /tikun_olam/index.php?pagename=$1&page=$2 [QSA,L]
RewriteRule ^(contact)/trackback/?$ /tikun_olam/index.php?pagename=$1&tb=1 [QSA,L]
RewriteRule ^(archives-monthly)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(archives-monthly)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(archives-monthly)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?pagename=$1&paged=$2 [QSA,L]
RewriteRule ^(archives-monthly)(/[0-9]+)?/?$ /tikun_olam/index.php?pagename=$1&page=$2 [QSA,L]
RewriteRule ^(archives-monthly)/trackback/?$ /tikun_olam/index.php?pagename=$1&tb=1 [QSA,L]
RewriteRule ^feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?&feed=$1 [QSA,L]
RewriteRule ^(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?&feed=$1 [QSA,L]
RewriteRule ^page/?([0-9]{1,})/?$ /tikun_olam/index.php?&paged=$1 [QSA,L]
RewriteRule ^comments/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?&feed=$1&withcomments=1 [QSA,L]
RewriteRule ^comments/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?&feed=$1&withcomments=1 [QSA,L]
RewriteRule ^comments/page/?([0-9]{1,})/?$ /tikun_olam/index.php?&paged=$1 [QSA,L]
RewriteRule ^search/(.+)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?s=$1&feed=$2 [QSA,L]
RewriteRule ^search/(.+)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?s=$1&feed=$2 [QSA,L]
RewriteRule ^search/(.+)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?s=$1&paged=$2 [QSA,L]
RewriteRule ^search/(.+)/?$ /tikun_olam/index.php?s=$1 [QSA,L]
RewriteRule ^category/(.+)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?category_name=$1&feed=$2 [QSA,L]
RewriteRule ^category/(.+)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?category_name=$1&feed=$2 [QSA,L]
RewriteRule ^category/(.+)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?category_name=$1&paged=$2 [QSA,L]
RewriteRule ^category/(.+)/?$ /tikun_olam/index.php?category_name=$1 [QSA,L]
RewriteRule ^author/([^/]+)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^author/([^/]+)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?author_name=$1&feed=$2 [QSA,L]
RewriteRule ^author/([^/]+)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?author_name=$1&paged=$2 [QSA,L]
RewriteRule ^author/([^/]+)/?$ /tikun_olam/index.php?author_name=$1 [QSA,L]
RewriteRule ^([0-9]{4})/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&feed=$2 [QSA,L]
RewriteRule ^([0-9]{4})/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&feed=$2 [QSA,L]
RewriteRule ^([0-9]{4})/page/?([0-9]{1,})/?$ /tikun_olam/index.php?year=$1&paged=$2 [QSA,L]
RewriteRule ^([0-9]{4})/?$ /tikun_olam/index.php?year=$1 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /tikun_olam/index.php?year=$1&monthnum=$2&paged=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/?$ /tikun_olam/index.php?year=$1&monthnum=$2 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&monthnum=$2&day=$3&feed=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&monthnum=$2&day=$3&feed=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /tikun_olam/index.php?year=$1&monthnum=$2&day=$3&paged=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /tikun_olam/index.php?year=$1&monthnum=$2&day=$3 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/feed/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&monthnum=$2&name=$3&feed=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/(feed¦rdf¦rss¦rss2¦atom)/?$ /tikun_olam/index.php?year=$1&monthnum=$2&name=$3&feed=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$ /tikun_olam/index.php?year=$1&monthnum=$2&name=$3&paged=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$ /tikun_olam/index.php?year=$1&monthnum=$2&name=$3&page=$4 [QSA,L]
RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)/trackback/?$ /tikun_olam/index.php?year=$1&monthnum=$2&name=$3&tb=1 [QSA,L]

[edited by: jdMorgan at 9:21 pm (utc) on July 5, 2005]
[edit reason] Removed URL, added code. [/edit]

richards1052

9:56 am on Jun 25, 2005 (gmt 0)

10+ Year Member



And here's the rule we added to .htaccess on June 23rd:
RewriteCond %{QUERY_STRING} ^/([^.]+)(.htm) [OR] RewriteCond %{QUERY_STRING} ^/([^.]+)(.jpg) RewriteRule ^.shared/image.html$ /%1%2 [R=301,L]

For some reason, this rule seems to working (it was intended to allow for display of images imported from my old Typepad blog). But it's caused a conflict with the permalink conversion rules which is preventing them from working.

jdMorgan

9:24 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The formatting of the code you added on the 23rd appears to be incorrect, in that each directive should be on a separate line. I assume that this is actually the case, so the next question is, did you add the new code above or below the existing code?

Jim

richards1052

6:06 am on Jul 7, 2005 (gmt 0)

10+ Year Member



My rewrite rules begin with (remember these are rules for a Wordpress site):

'#Begin WordPress'

and they end with

'#End Wordpress'

I worked with someone who told me to insert the JUne 23rd jpg rules into the middle of the existing code. Based on what others have told me since perhaps I shouldn't have done that & perhaps that's what the conflict is. If I add the jpg related code either before 'Begin' or after "End" would that work better?

richards1052

6:18 am on Jul 7, 2005 (gmt 0)

10+ Year Member



Come to think of it the rewrite rules added on June 23rd were meant to facilitate display of images. Despite my htaccess directive error the images now display fine. So that's not the problem.

The problem is with the other rewrite rules which are supposed to allow the underscore-formatted links (my old Typepad format) to convert to hyphen-formatted links (my new wordpress format). They're roughly the last 10-12 rewrite rules in the file above. That's where I need help.

jdMorgan

6:06 pm on Jul 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Again, be careful of your formatting; One directive per line and no line breaks allowed within a directive. The error log implies that the parser is seeing "\xef\xbb\xbf" at the beginning of a line and is trying to "execute" it.

If all else fails, wait till your traffic is minimum, and then delete all of the rules, adding them back a few at a time and testing until you find the rule that fails.

Jim

richards1052

5:09 am on Jul 8, 2005 (gmt 0)

10+ Year Member



I've moved the rules regarding the image file displays so they're outside of the rules specific to my WordPress installation. Now, I don't see any error msg. in the .htaccess file. But I still have no link redirection allowing visitors to use old links to get to my new posts, which those final set of rules are supposed to deal with.