[英]Url rewriting different name for file if empty
嗨,我有一個重寫來添加作者姓名,以便:
example.com/author/first-name-last-name
現在,當有人導航到:
example.com/author
它顯示了所有作者,但是我希望該網址為
example.com/authors
末尾帶有“ s”。 如何在不重定向到名為authors.php的實際頁面的情況下實現此目標?
我當前的規則是:
RewriteRule ^author/([A-Za-z0-9-]+)/?$ author.php?authorslug=$1 [NC,L]
在已有規則之前添加一條規則:
RewriteRule ^author/?$ /authors.php [L]
大概這就是您要尋找的:
RewriteEngine On
# show all authors
RewriteRule ^authors/?$ /author.php [L]
# show a particular author
RewriteRule ^author/([a-z0-9-]+)/?$ author.php?authorslug=$1 [NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.