2015-01-01 75 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