RewriteRule in .htaccess not working

前端 未结 3 365
野的像风
野的像风 2021-01-12 19:56

I am currently running Apache2 on my local machine, installed with the latest version of Ubuntu.

I am trying to get basic URL rewriting working by using the .htacces

相关标签:
3条回答
  • 2021-01-12 20:45

    For the benefit of others, I figured out the answer:

    In the file "/etc/apache2/sites-enabled/000-default" there was the line:

    AllowOverride None
    

    Change this to:

    AllowOverride All
    
    0 讨论(0)
  • 2021-01-12 20:48

    You need to remove the contextual path prefix from your pattern when using mod_rewrite in a .htaccess file. In the case of the root directory, the path prefix is just /. So try this:

    RewriteRule ^doesnotexist/(.*)$ /page.php?p=$1
    
    0 讨论(0)
  • 2021-01-12 20:53

    If I place a .htaccess into /Library/WebServer/Documents and open "localhost/"; to test it, this works as expected. It just doesn't work in "~/Sites". I have tried this on Mac OS X Mavericks.

    0 讨论(0)
提交回复
热议问题