0

This is my rule:

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

If $2 doesn't exist (URL doesn't have two slashes), I want to echo '/' instead of '.php'. So the condition becomes:

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

How do I do this or archive the same result?

4

2 回答 2

1

很确定这就是 RewriteCond 的用途!

RewriteEngine on

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

RewriteCond %{REQUEST_URI} ^/([^/]+)$
RewriteRule ^([^/]+)(/.+)? /negocio/?shopURL=$1 [L,QSA]
于 2012-05-16T19:34:14.340 回答
0

用这个替换你的代码:

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

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

RewriteRule ^([^/]+)(/.+?)/?$ negocio$2.php?shopURL=$1 [L,QSA]
于 2012-05-16T20:29:51.307 回答