.htaccess重写规则/目录/到php文件?

时间:2012-05-16 17:43:43

标签: .htaccess

我想转:

/1/2

成:

/negocio/2.php?shopURL=1

我对htaccess知之甚少,我的规则不起作用。这就是我试过的:

RewriteRule ^([^/]+)(/.+)? /negocio$2.php/?shopURL=$1 [L,QSA]

3 个答案:

答案 0 :(得分:1)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

RewriteRule ^([^/]+)(/.+?)/?$ negocio$2.php?shopURL=$1 [L,QSA]

答案 1 :(得分:0)

试试这个:

上的RewriteEngine

RewriteBase /

RewriteRule ^ 1/2 /(.*)http://www.example.com/negocio/2.php?shopURL=1 [L,QSA]

答案 2 :(得分:0)

在.htaccess中试试

RewriteEngine on

RewriteBase /

RewriteCond $1 !^(negocio)
RewriteRule ^(.*)$ negocio/$1.php [L,QSA]