zoukankan      html  css  js  c++  java
  • Ubuntu

    1. .htaccess放到网站根目录

    RewriteEngine On
    
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^topic-(.+).html$ portal.php?mod=topic&topic=$1&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^article-([0-9]+)-([0-9]+).html$ portal.php?mod=view&aid=$1&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^forum-(w+)-([0-9]+).html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+).html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^group-([0-9]+)-([0-9]+).html$ forum.php?mod=group&fid=$1&page=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^space-(username|uid)-(.+).html$ home.php?mod=space&$1=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^blog-([0-9]+)-([0-9]+).html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1
    RewriteCond %{QUERY_STRING} ^(.*)$
    RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_-]+).html$ plugin.php?id=$1:$2&%1

    2. 开启mod_rewrite模块

    可以通过phpinfo()函数来查看mod_rewrite是否开启。

    开启方法:

    sudo a2enmod rewrite           //即启用了 Mod_rewrite 模块。

    另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块。

    用指令操作就是:

    sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

    3. 将AllowOverride设为All (注意是2个地方)

    sudo vim /etc/apache2/sites-enabled/000-default

    DocumentRoot /var/www
    <Directory />
    Options FollowSymLinks
    AllowOverride All
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>

    最后,重启 Apache:

    sudo /etc/init.d/apache2 restart.

    另外补充CentOS的

    /etc/httpd/conf/httpd.conf

    /etc/httpd/conf.d/php.conf
    修改这两个文件的 AllowOverride 
  • 相关阅读:
    找出数组中重复的值
    算法-二分法查询
    MySQL连接数据库url的参数characterEncoding=UTF-8
    String 与 list 相互转换
    php配置debug
    ideal+php
    命令行编译tomcat项目
    jsp+layui导出excel
    jsp+ssm+tomcat+ueditor上传定时处理无用文件
    jsp后台获取项目路劲
  • 原文地址:https://www.cnblogs.com/gb2312/p/3691477.html
Copyright © 2011-2022 走看看