分类:运维 发布时间:2016-08-15 14:27:00
一、配置服务器启动重写模块 打开 Apache 的配置文件 httpd.conf 。 将 #LoadModule rewrite_module modules/mod_rewrite 前面的#去掉。 保存后重启Apache 二、编辑 .htaccess 文件 例如,我们要让 http://192.168.188.32/product 指向 http://192.168.188.32/index.php?c=product ``` RewriteEngine on //让url重写生效 RewriteRule ^(\w{0,}$ index.php?c=$1 //前面为正则,后面为匹配项 ``` 我们也可以根据条件重写下面是让没有找到的文件和目录都指向 index.php ``` RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f //查找不到的文件 RewriteCond %{REQUEST_FILENAME} !-d //查找不到的目录 RewriteRule ^(.*)$ index.php [L] //所有访问跳转到路径index.php ``` 三、完成以上两部后加入伪静态未成功,打开配置文件 httpd.conf,找到网站配置,查看 Directory 内容是否完整,没有就添加上去 ``` <VirtualHost *:80> DocumentRoot /var/www/html/hooppay ServerName www.xzshop2.com <Directory /var/www/html/hooppay > Options Indexes FollowSymLinks AllowOverride ALL Order allow,deny Allow from all </Directory> </VirtualHost> ```
搜索
文章分类
最新文章