linux Ubuntu apache2 伪静态设置

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 (我这边是/etc/apache2/apache2.conf)

3.在你的网站的目录下建立.htaccess文件
并建立如下内容
RewriteEngine on

(在这个地方如果报

[Sat Jan 24 07:51:53.568313 2015] [core:alert] [pid 1043] [client 101.130.216.102:51423] /var/www/html/.htaccess: Invalid command 'ewriteEngine', perhaps misspelled or defined by a module not included in the server configuration错误,很可能是因为拼写错误,我在第一次配置的时候把RewriteEngine on写成了ewriteEngine on

报错的话可以 vim /var/log/apache2/error.log

查看)
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.测试

在show.php 输入

<?php 
echo $_GET['itemid'].$_GET['page'];
?>

转载于:https://www.cnblogs.com/ylks/p/4244692.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值