Apache htaccess有一定的url匹配加载文件


apache htaccess have certain url matches load a file

如何使某些url正则表达式匹配加载一个文件?

例如:

.com/people, .com/people/john, .com/people/* =>全负载./people.php

.com/animals, .com/pokemon => both load ./index.php

有许多指向相同内容的路由是一个坏主意(这会导致重复的内容,这不利于引用)

无论如何,这里的代码提供了你所要求的(把这段代码放在你的htaccess,它必须在根文件夹)

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteRule ^people/? /people.php [L]
RewriteRule ^(animals|pokemon)$ /index.php [L]