开发者

how can i solve this htaccess problem

i have following dynamic url...

http://www.mydomain.com/v/dynamicvaluehere

and i have following in my htaccess

RewriteRule ^v/(.*)$ script.php?name=$1 [NC,L]

and it is working fine now i want to create further i.e

http://www.mydomain.com/v/dynamicvaluehere/Page-dyanamicnumberhere.html

and i have following in my htaccess

Rewr开发者_Go百科iteRule ^v/(.*)/Page-(.*)\.html$ script.php?name=$1&number=$2 [NC,L]

but it is not working please help... also do note that the dynamicvalue mentnioned secondly is samy as mentioned above but only dynamicnumber is further included...


I think the problem might be your use of wildcards. If your .htaccess looks like this:

RewriteRule ^v/(.*)$ script.php?name=$1 [NC,L]
RewriteRule ^v/(.*)/Page-(.*)\.html$ script.php?name=$1&number=$2 [NC,L]

then no pattern will ever reach the second argument because (.*)/Page-(.*)\.html will actually fall under (.*) first.

You could either refine your wildcards to something like this:

RewriteRule ^v/([A-Za-z0-9].*)$ script.php?name=$1 [NC,L]
RewriteRule ^v/([A-Za-z0-9].*)/Page-([0-9].*)\.html$ script.php?name=$1&number=$2 [NC,L]

or maybe even try switching the order of your statements to:

RewriteRule ^v/(.*)/Page-(.*)\.html$ script.php?name=$1&number=$2 [NC,L]
RewriteRule ^v/(.*)$ script.php?name=$1 [NC,L]


Your second rule is never being reached because of the greedy nature of the first. You can either put it above the first rule or make your first rule more specific.

Try the following:

RewriteRule ^v/(.+)/Page-(.+)\.html$ script.php?name=$1&number=$2 [NC,L]
RewriteRule ^v/(.*)$ script.php?name=$1 [NC,L]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜