.htaccess页面重新路由 - 获得404

时间:2017-06-15 12:53:59

标签: url-rewriting

我想使用我的.htaccess文件来确保以下路由发生:

  

success_stories.php - > success_storie

这是我尝试过的,但它没有用,因为我得到了404。

Options -MultiViews +FollowSymLinks
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^success_stories.php$ /success_storie [L,R,NC]

1 个答案:

答案 0 :(得分:1)

尝试类似的东西

## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]