.htaccess在子目录中重写

时间:2014-07-22 08:21:50

标签: php apache .htaccess mod-rewrite rewrite

我安装了wamp服务器,我无法从子目录

重写我的网址
http://localhost/new1/articles/details.php?name=test

http://localhost/new1/articles/test

我试过这个

RewriteEngine On

RewriteRule ^new1/articles/(.*)/$ /new1/articles/details.php?name=$1 [L,R=301]

和这个

RewriteCond /articles/ -d
RewriteRule ^/articles/([^/]*)  /articles/details.php?name=$1

什么都行不通......我找不到404了。 我做错了什么?

1 个答案:

答案 0 :(得分:0)

将此规则放在/new1/.htaccess

RewriteEngine On
RewriteBase /new1/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^articles/([^/]+)/?$ articles/details.php?name=$1 [L,QSA,NC]