使用htaccess映射网址链接

时间:2014-02-25 00:27:36

标签: apache .htaccess url mod-rewrite url-rewriting

我正在尝试制作这个网址:

http://www.site.com/blog

http://www.site.com/blog/category/showcase

这样的事情不起作用:

RewriteRule ^blog$ /blog/category/showcase

或:

RewriteRule ^blog$ http://www.site.com/blog/category/showcase [R=301,L]

有任何想法吗?

1 个答案:

答案 0 :(得分:0)

在内部重写之前保留301。您可以使用:

RewriteEngine On
RewriteBase /blog/

RewriteRule ^$ category/showcase [R=301,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [L]