Forum Moderators: phranque

Message Too Old, No Replies

.htaccess Rewrite COND help

         

ComputerDoctor

10:22 pm on Feb 8, 2010 (gmt 0)

10+ Year Member



I keep getting a 500 Internal Server Error that logs with ".htaccess:RewriteCond: bad flag delimiters"

The script is as followed:
# Turn off directory browsing
# Options -Indexes # Start the rewrite engine
RewriteEngine On # Make sure the user included www.
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,L]

Can anyone point me at my error?

[edited by: jdMorgan at 2:18 pm (utc) on Feb 9, 2010]
[edit reason] Please use example.com. See TOS and Charter. [/edit]

g1smd

11:50 pm on Feb 8, 2010 (gmt 0)

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



The r= should be R= instead.

Move the comment that is currently on the same line as some code, so that it is on a separate line above the code.

ComputerDoctor

6:00 pm on Feb 9, 2010 (gmt 0)

10+ Year Member



This didn't solve my problem, unfortunately. I still am getting the 500 Internal Error. With the Bad flag delimiters.... Below I've copied the whole .htaccess

# Turn off directory browsing
# Options -Indexes # Start the rewrite engine
# Make sure the user included www.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
# Compress the stylesheet
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Give pages pretty URLs
RewriteRule ^([^/]+).css$ classes/CompressStyles.php?sheet=$1
# Lame and Juicy buttons
RewriteRule ^([0-9a-zA-Z\-]+)$ $1.php
RewriteRule ^([0-9a-zA-Z\-\\/]*)lame/([0-9]+)$ rate.php?value=-1&secretID=$2
RewriteRule ^([0-9a-zA-Z\-\\/]*)juicy/([0-9]+)$ rate.php?value=1&secretID=$2

# View comments
RewriteRule ^view/([0-9]+)$ comments.php?secretID=$1

# Delete comment
RewriteRule ^([0-9a-zA-Z\-\\/]*)delete-comment/([0-9]+)$ delete-comment.php?commentID=$2 # Delete entry
RewriteRule ^([0-9a-zA-Z\-\\/]*)delete-entry/([0-9]+)$ delete-entry.php?secretID=$2

# Edit entry
RewriteRule ^([0-9a-zA-Z\-\\/]*)edit-entry/([0-9]+)$ edit-entry.php?secretID=$2

# View category
RewriteRule ^view/([a-zA-Z\-]+)$ view-category.php?category=$1

# Pagination
RewriteRule ^([0-9a-zA-Z\-]+)/page([0-9]+)$ $1.php?page=$2
RewriteRule ^view/([0-9\-]+)/page([0-9]+)$ comments.php?secretID=$1&page=$2
RewriteRule ^view/([a-zA-Z\-]+)/page([0-9]+)$ view-category.php?category=$1&page=$2
RewriteRule ^page([0-9]+) index.php?page=$1
RewriteRule ^search/([0-9a-zA-Z\-\%\+]+)/page([0-9]+)$ search.php?query=$1&page=$2

# Secret submission
RewriteRule ^thank-you upcoming.php?submitted=true

# Admin Page
RewriteRule ^([0-9a-zA-Z\-\\/]*)admin admin/index.php

# Button clicking
RewriteRule ^images/buttons/([0-9a-zA-Z\-]+).png$ classes/Button.php?text=$1

# Mask all XML files as PHP pages
RewriteRule ^(.+).xml $1.php

# Page not found
ErrorDocument 404 /page-not-found

jdMorgan

12:12 am on Feb 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You still have a comment on a code line... "Delete entry"

mod_rewrite is not at all a 'free-form' coding language. Your code needs to look *exactly* like the documentation shows.

You're also missing [L] flags on almost all of these rules.

You can replace "([a-zA-Z\-]" with "([a-z\-]" and use the [NC] flag for a good speed-up.

Jim

ComputerDoctor

3:59 pm on Feb 10, 2010 (gmt 0)

10+ Year Member



When you purchase a script package to make your life easier--you'd think it would be easier. Hardly.

I'll fool around with this, but I don't have a clue what I'm doing.

jdMorgan

5:28 pm on Feb 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The resources cited in our Apache Forum Charter and the threads in our Apache Forum Library may prove helpful.

Links to these pages are at the top left of this screen.

Jim