mod_rewrite gives error UNLESS slash at end of URL

Hello.

I put this in the .htaccess file in my "demo" directory:
          RewriteEngine on
          RewriteRule edit demo_admin [NC]
          RewriteRule admin demo_admin [NC]


It works, but now when someone types in

          http://www.mysite.com/demo
 
                     they get an error.  They must put a slash on the end:
 
          http://www.mysite.com/demo/


How can I fix this so the slash at the end is optional?

Thanks!
LVL 16
hankknightAsked:
Who is Participating?
 
ramazanyichConnect With a Mentor Commented:
ahofmann is correct in most cases it is a problem with ServerName directive.
But if you don't have access to the httpd.conf file then you can try to fix it by RewriteRule in .htaccess. Check http://httpd.apache.org/docs/misc/rewriteguide.html (search for "Trailing Slash Problem" part of that document)
0
 
ahoffmannConnect With a Mentor Commented:
please check the response you get for  http://www.mysite.com/demo
it should be a
  301 Moved
with a
  Location: http://www.mysite.com/demo/

if not, you most likely have not set a proper ServerName in httpd.conf
0
 
hankknightAuthor Commented:
http://www.mysite.com/demo/

      gives me  "200" OK

http://www.mysite.com/demo

      gives me  400 Bad Request

I have root access and can change my httpd.conf file.  What should I do there to fix this?

Thanks!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
ramazanyichConnect With a Mentor Commented:
if you have access to httpd.conf first try to put following directve to httpd.conf into your Virtual Server section:
ServerName www.mysite.com
0
 
hankknightAuthor Commented:
Thanks.

       ServerName www.mysite.com

is already there, and in the right place.  Any more ideas?

0
 
ramazanyichCommented:
did you check error.log file? In most cases there you can find more detailed information about error.
0
 
hankknightAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.