【问题标题】:Map url link with htaccess使用 htaccess 映射 url 链接
【发布时间】:2014-02-25 00:27:36
【问题描述】:

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

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]

对此有什么想法吗?

【问题讨论】:

  • 您的 .htaccess 中是否还有更多规则?
  • @anubhava 这里是 .htaccess sharetext.org/da3y

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


【解决方案1】:

在内部重写之前保留您的 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]

【讨论】:

    猜你喜欢
    • 2015-01-14
    • 2019-11-18
    • 2012-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多