我有以下代码:

RewriteRule ^fishing/([^/]*)/([^/]*) fishery.php?url=$2&region=$1 [L]
RewriteRule ^fishing/([^/]*) region.php?region=$1 [L]

当我输入domain.com/fishing/fife时,它会显示正确的region.php文件。
但是,如果我在domain.com/fishing/fife/中键入结尾处的“/”,则它将加载fishire.php页面。我怎样才能防止这种情况?
其次,如果它加载为/fishing/fife而不是fishing/fife.php,那么对于搜索引擎优化来说有什么坏处吗?毕竟这是一页而不是一个目录?如果这不重要,那么我更希望它没有.php,因为它看起来更整洁。
提前谢谢

最佳答案

我认为应该这样做:

RewriteRule ^fishing/([^/]*)/([^/]+) fishery.php?url=$2&region=$1 [L]
RewriteRule ^fishing/([^/]*)/?$ region.php?region=$1 [L]

另外,有一个“目录”的网址而不是一个页面也没有什么错,事实上我认为这可能是更好而不是更糟的搜索引擎优化…

关于apache - 用户友好的URLS .htaccess,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10134951/

10-10 00:08