Ubuntu Apache 伪静态配置 url重写

Linux大全评论712 views阅读模式

Ubuntu Apache 伪静态配置 url重写 步骤:
1.加载rewrite模块
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

2.将您的主机的<Directory></Directory>中的AllowOverride None改为AllowOverride All

3.在你的网站的目录下建立.htaccess文件
并建立如下内容
RewriteEngine on
RewriteBase   /
RewriteRule ^(.*)show-([0-9]+)-([0-9]+)\.html$ $1/show.php?itemid=$2&page=$3

其中RewriteRule是例子,意思为在浏览器中输入的是show-1-2.html,而实际访问的却是show.php?itemid=1&page=2

4.重启apache2

5.测试

企鹅博客
  • 本文由 发表于 2020年6月19日 12:54:09
  • 转载请务必保留本文链接:https://www.qieseo.com/140447.html

发表评论