我想这样:
http://www.website.com/test/view
实际上称之为:
http://www.website.com/index.php/test/view
我尝试了一个看起来像这样的.htaccess文件,但它似乎不起作用:
RewriteEngine on
RewriteCond $1 !^index\.php
RewriteRule ^(.*)$ /index.php/$1 [L]
我错过了什么?
答案 0 :(得分:1)
你在第一行设置了“RewriteEngine On”吗?
我曾经使用过一次这对我来说很好用:
RewriteEngine On
RewriteRule ^([a-z\-]+)$ /index.php?page=$1 [L]
答案 1 :(得分:1)
通过httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放在.htaccess
目录下的DOCUMENT_ROOT
中:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php%{REQUEST_URI} [L]