[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

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!
0
hankknight
Asked:
hankknight
  • 3
  • 3
3 Solutions
 
ahoffmannCommented:
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
 
ramazanyichCommented:
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
 
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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
ramazanyichCommented:
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

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now