与mod_rewrite有一些问题

时间:2012-10-14 19:37:48

标签: php apache .htaccess mod-rewrite hyperlink

Options +FollowSymLinks  
RewriteEngine On  
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^profile/(\w+)/*$ ./index.php?page=showuser&username=$1

好的,所以我有这个代码可以完全按照它的意思重写我的URL(sitename / profile / username)。

现在假设我只想访问(sitename / profile /)。我必须写什么规则才能使其工作而不是给我一个错误?

我是mod重写的新手,所以如果这个问题对你们这些人来说似乎很蠢,我很抱歉。

1 个答案:

答案 0 :(得分:2)

RewriteRule ^profile/$ ./index.php?page=profile [L,NC]

最后的美元与网址的结尾相匹配。在这种情况下,profile/

之后不会有任何其他内容