2015-01-01 76 views
0

我刚开始试图让漂亮的URLs工作,我从来没有与他们合作过。 我得到它的工作,如果它只是像example.com/first这样的'目录',但当我尝试与另一个'子目录'有promlem(exaple.com/first/second)漂亮的URL多​​级

这是两个在底部不起作用。

Options +FollowSymLinks 
RewriteEngine On 

RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteCond %{SCRIPT_FILENAME} !-f 

RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1 #works 
RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 #works 

RewriteRule ^partier/([a-zA-Z0-9]+)/$ index.php?page=partier&parti=$2 #Don't work 
RewriteRule ^partier/([a-zA-Z0-9]+)$ index.php?page=partier&parti=$2 #don't work 
#www.example.com/partier/[your choice]/ --> www.example.com/index.php?page=partier&parti=[Your choice] 

回答

1

使用:

Options +FollowSymLinks 
RewriteEngine On 

# skip all files and directories from rewrite rules below 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

RewriteRule ^([a-z0-9]+)/?$ index.php?page=$1 [NC,L] 
RewriteRule ^partier/([a-z0-9]+)/?$ index.php?page=partier&parti=$1 [NC,L] 
+0

做NC,L满足什么purpos? – Olof

+0

L =最后。和NC = nocase。你可以在这里阅读:[doc](http://httpd.apache.org/docs/2.2/rewrite/flags.html) – Croises