php wamp htaccess 伪静态配置无效的问题

来源:互联网 发布:mac点不开 app store 编辑:程序博客网 时间:2024/06/10 02:28

去掉LoadModule rewrite_module modules/mod_rewrite.so前面的#
以及 AllowOverride All 就不提了。
部分博客提到 AccessFileName access.ht问题,有需要也可以看看。


不过以上都没有问题还是不行。
看了thinkPhp5 自带的htaccess文件才发现,是写错了rule。
看的视频教程上提供的规则如下:
RewriteEngine onRewriteRule ^/test([0-9]*).html$ /test.php?id=$1 RewriteRule ^/new([0-9]*)/$ /new.php?id=$1 [R]


结果无论如何都无效
tp5的代码如下:
<IfModule mod_rewrite.c>  Options +FollowSymlinks -Multiviews  RewriteEngine On  RewriteCond %{REQUEST_FILENAME} !-d  RewriteCond %{REQUEST_FILENAME} !-f  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>


在rule一行,少了一个“/”,就只是这问题。
实际测试,只写
  RewriteEngine On  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

就够了。
假如规则写成
 
RewriteEngine On RewriteRule ^(.*)$ index.php?id=$1 [QSA,PT,L]

那么 访问 http://localhost/文件路径/111
        相当于访问     
          http://localhost/文件路径/index.php?id=111







0 0
原创粉丝点击