• 如果是apache2(.4.18)
    1. 参考链接
    2. 在~/sites-available/x.conf中 我的主页网站的<VirtualHost>标签里添加如下代码就可
      <Directory /var/www/ztyii>
      Options FollowSymLinks IncludesNOEXEC Indexes
      AllowOverride all
      Require all granted
    3. 然后打开apache2的rewrite功能,重启即可
      sudo a2enmod rewrite
      sudo service apache2 restart
  • 如果是 Nginx
    1. 修改网站配置文件(默认路径/etc/nginx/sites-available/default),在server块中添加
      location / {
      # First attempt to serve request as file, then
      # as directory, then fall back to displaying a 404.
      try_files $uri $uri/ =404;
      index index.php;
      root /var/www/ztyii; #修改为自己的网站根目录
      if (-f $request_filename/index.html){
              rewrite (.*) $1/index.html break;
      if (-f $request_filename/index.php){
              rewrite (.*) $1/index.php;
      if (!-f $request_filename){
              rewrite (.*) /index.php;
    2. 重启Nginx服务
      sudo service nginx restart

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.