.htaccess not working (mod_rewrite)

前端 未结 16 1790
遇见更好的自我
遇见更好的自我 2020-12-08 05:05

I have not having any luck getting my .htaccess with mod_rewrite working. Basically all I am trying to do is remove \'www\' from \"http://www.example.com\" and \"https://ww

16条回答
  •  半阙折子戏
    2020-12-08 05:28

    You can easily test if your htaccess is being read or not:

    • Put garbage in it, like:

      Options +FollowSymLinks
      This is garbage
      RewriteEngine on
      RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
      RewriteRule (.*) //%1/$1 [L,R=301]
      

      If you get a 500 error (Internal Server Error) then it IS being read.

      If it is, you should enable the RewriteLog in the main server configuration (not in .htaccess) like this:

      RewriteLog "/tmp/rewrite.log"
      RewriteLogLevel 9
      

    And then check the file /tmp/rewrite.log to see what's happening. Report back with results.

    (Stack Overflow isn't a good debugging medium, IRC is better for that, try #apache@irc.freenode.net)

    Good luck.

提交回复
热议问题