开发者

.htaccess specific problem with formation

开发者 https://www.devze.com 2023-03-19 00:34 出处:网络
If format is Dir-$mrpagename-$mrid.htm then .htaccess is Options +FollowSymLinks RewriteEngine on RewriteRule Dir-(.*)-(.*)\\.htm$ index.php?page=browse&category=$2

If format is Dir-$mrpagename-$mrid.htm then .htaccess is

Options +FollowSymLinks
RewriteEngine on
RewriteRule Dir-(.*)-(.*)\.htm$ index.php?page=browse&category=$2

for http://sitename/Dir-dirbrowse-3.htm

But if format is $mrpagename-$mrid then what will be .htaccess for http://sitename/dirb开发者_如何转开发rowse-3?


RewriteRule ^([a-z0-9]+)-(\d+)$ /index.php?page=browse&category=$2 [NC,L]

Based on your example dirbrowse-3 ($mrpagename-$mrid) I put these "restrictions" to properly match URLs (you will need to modify this rule if these parts can have any other characters):

  • $mrpagename part can be letters or digits
  • $mrid part can only be digits

I did it (restrictions) because your original rule (the (.*) part) is quite broad and can catch other forms of URLs as well which may lead to category parameter having invalid data.

0

精彩评论

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

关注公众号