如果url / word为小写,则返回未找到RewriteRule

时间:2016-08-27 20:30:14

标签: .htaccess mod-rewrite

我通过htaccess重写一个url,但是如果我用小写字母写它或者不是我们用RewriteRule写的它将无效,返回找不到的文件或对象。如果我写的示例转到url ACTIVATE/TheTokenKey返回未找到。是否有任何可以将url读取为小写的内容,因此,如果我们写AcTivAtE,则会将其读为activate

RewriteBase /
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^Activation/(.*)$ ?tab=activation&token=$1 [L]

1 个答案:

答案 0 :(得分:0)

使用规则上的from django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): name = models.OneToOneField(User) def __unicode__(self): return self.user.user_name class Category(models.Model): category = models.CharField(max_length=150) def __str__(self): return self.category class Blog(models.Model): title = models.CharField(max_length=150, default="No title") body = models.TextField(default="None") creation_date = models.DateTimeField(auto_now_add=True) author = models.ForeignKey(UserProfile, default=1) category = models.ForeignKey(Category, default="None") def __str__(self): return self.title class Comment(models.Model): comment = models.TextField(default="") blog = models.ForeignKey(Blog) 标记

[NC]
  

使用[NC]标志会使RewriteRule在a中匹配   不区分大小写的方式。也就是说,它不关心是否是字母   在匹配的URI中显示为大写或小写。

https://httpd.apache.org/docs/current/rewrite/flags.html