570
文章
·
29547
阅读
570
文章
·
29547
阅读

有28人阅读过 网站设置伪静态
发布于2023/10/30 更新于2023/10/30
[ 教程仅保证更新时有效,请自行测试。]

在网站根目录创建文件.htaccess

文件内容如下:


Apache伪静态:

<IfModule mod_rewrite.c>
RewriteEngine on
# Apache 2.4
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*?)([^/]*)$ $1index.php?$2 [QSA,PT,L]
# Apache other
#RewriteRule ^(.*?)([^/]*)\.htm(.*)$ $1/index.php?$2.htm$3 [L]
</IfModule>


Nginx伪静态:

location ~* \.(htm)$ {
    rewrite "^(.*)/(.+?).htm(.*?)$" $1/index.php?$2.htm$3 last;
}


Caddy伪静态(Caddyfile演示):

www.yourdomain.com {
# Set this path to your site's directory.
root * /var/www
file_server
# Or serve a PHP site through php-fpm:
php_fastcgi localhost:9000
}


文章对你有帮助吗?
  • 一般[0]
  • 很赞[0]
  • 没用[0]
  • 垃圾[0]
  • 无语[0]
扫一扫,手机浏览手机访问本站