_escape_fragment_的重写规则

时间:2013-03-27 17:01:30

标签: ajax .htaccess seo

我想为

写一个重写规则

http://www.site.com/noticia/?_escaped_fragment_=noticia=/279/beto-cuevas3er-sencillo-dej-de-pensar

为:

http://www.site.com/noticia/#!noticia=/279/beto-cuevas3er-sencillo-dej-de-pensar

我试过这个但是远远不是我需要的吗?

# Enable Rewrite Engine
RewriteEngine on

#Create friendly URL
RewriteRule ^index.php?_escaped_fragment=something=yes$ 
index.php/#!something=yes [L]

1 个答案:

答案 0 :(得分:1)

通过httpd.conf启用mod_rewrite和.htaccess,然后将此代码放在.htaccess目录下的DOCUMENT_ROOT中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^_escaped_fragment_=([^=]+)=([^&]+) [NC]
RewriteRule ^$ /%1/#!%1=%2? [L,R,NE]