apache伪静态把css 排除掉_表白页面404登录注册404伪静态解决方案

请根据自己的环境选择伪静态规则.

有的朋友不知道自己是什么环境的, 可以通过管理员后台首页查看

45f521461e77d0a09b3e358e89cf4dcd.png

45f521461e77d0a09b3e358e89cf4dcd.png

通常大家用的环境都是 IIS, APACHE ,NGINX (还是补充个小写吧 iis, apache, nginx)

大部分国内空间用的都是 IIS 以及 APACHE

而且都有切换PHP版本的功能, 我建议大家将PHP版本提升到最高.

Apache伪静态

Apache的伪静态是最简单 易用的.

直接在网站根目录下创建文件:.htaccess (注意: 不要在前面加什么 x.htaccess . 该文件不需要文件名 只需要后缀)

写入内容:

<IfModule mod_rewrite.c>

Options +FollowSymlinks

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]

</IfModule>

如果完成以上操作 依然无法使用. 那可能是你的Apache为开启伪静态模块

在Apache 安装目录中找到conf/httpd.conf文件

在该文件中搜索 : mod_rewrite

即可找到关键字

#LoadModule rewrite_module modules/mod_rewrite.so

如果你看到 前面有一个# 号 说明伪静态模块并未开启

所以你需要将 #号去除, 保存文件 重启Apache进程即可! 不会重启Apache的 请重启主机吧!

Nginx

Nginx的伪静态安装时比较麻烦的, 因为Nginx一般会在Linux下安装使用, 空间以及Windows用的较少.

你需要来到Nginx的Conf目录

这里用LNMP的安装目录作为说明

LNMP中的Nginx目录在 /usr/local/nginx中

# cd /usr/local/nginx/conf/vhost

在目录中找到你的网站目录vhost

(这里可能有人不理解 我也不知道怎么说的明白)

# vi 你的目录名.conf

打开文件后可见内容:

server

{

listen 80;

#listen [::]:80;

server_name http://bbs.hyphp.cn bbs.hyyyp.com;

index index.html index.htm index.php default.html default.htm default.php;

root /home/wwwroot/bbs.hyphp.cn;

include other.conf;

#error_page 404 /404.html;

include enable-php.conf;

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*.(js|css)?$

{

expires 12h;

}

......

........

...

省略..

在中间插入:

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=$1 last;

break;

}

server

{

listen 80;

#listen [::]:80;

server_name http://bbs.hyphp.cn bbs.hyyyp.com;

index index.html index.htm index.php default.html default.htm default.php;

root /home/wwwroot/bbs.hyphp.cn;

include other.conf;

#error_page 404 /404.html;

include enable-php.conf;

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=$1 last;

break;

}

location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$

{

expires 30d;

}

location ~ .*.(js|css)?$

{

expires 12h;

}

插入后就是上面的结构了

保存该Conf即可

重启Nginx 完成

IIS 7 以上

IIS7版本以上安装了URL重写支持才会支持Web.config伪静态

在根目录写入以下内容 保存为 Web.config

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<rewrite>

<rules>

<rule name="OrgPage" stopProcessing="true">

<match url="^(.*)$" />

<conditions logicalGrouping="MatchAll">

<add input="{HTTP_HOST}" pattern="^(.*)$" />

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />

<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />

</conditions>

<action type="Rewrite" url="index.php?s={R:1}" />

</rule>

</rules>

</rewrite>

<directoryBrowse enabled="false" />

<security>

<requestFiltering allowDoubleEscaping="True" />

</security>

</system.webServer>

</configuration>

IIS6

IIS6 是不支持web.Config的 所以你需要使用 ISAPI_Rewrite.dll 进行解析httpd.ini 那请用你的方法 将httpd.ini内容 配置到 IIS中

httpd.ini

[ISAPI_Rewrite]

# 3600 = 1 hour

CacheClockRate 3600

RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files

# from accessing through HTTP

RewriteRule (.*)$ /index.php?s=$1 [I]

如果你的空间支持 httpd.ini的话 那就在根目录中新建 httpd.ini这个文件 并写入上面的内容.并且你需要删除根目录下的 Web.config文件

如果你的IIS使用Web.config 那你就可以直接使用 根目录提供的Web.config文件

配置完成以及 进程或服务器 重启后 请回到管理员后台首页 查看服务器信息

46d6bc9073f95efa6362cb0cca5efb86.png

46d6bc9073f95efa6362cb0cca5efb86.png

如果提示 伪静态条件 为支持. 则可以开启伪静态

去掉?号 打开文件 /Conf/config.php 找到内容: //'REWRITE'=>1,//伪静态规则

a5aa6e24d6dd6cd6b7a5ecc9315b390f.png

a5aa6e24d6dd6cd6b7a5ecc9315b390f.png

去掉前面的 //

改为下图所示内容

6fbb117ba0cc903e66cf40d832074dbf.png

6fbb117ba0cc903e66cf40d832074dbf.png

保存文件即可!

伪静态安装完毕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值