首页 文章

htaccess重写为#!

提问于
浏览
3

召集所有.htaccess大师 . 我需要你的帮助!

我试图强制改写包含#!在网址中 .

所以基本上我需要 . http://example.com/biography

被重写为http://example.com/#!/biography

如果到目前为止,我的重写规则会有所不同

RewriteEngine On
  RewriteCond %{HTTPS} !=on

  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

  RewriteCond $1 !^(images|system|files|themes|static|favicon\.ico|robots\.txt|index\.php) [NC]
  RewriteRule ^(.*)$ /index.php/$1 [L]

我吮吸这些东西所以任何帮助将不胜感激 .

另外...

我有这个测试做我需要它在这个htaccess测试器做的事情 . http://htaccess.madewithlove.be/但是当我在我的网站上试用它时它不起作用......

RewriteCond %{REQUEST_URI} !^/#!
RewriteRule ^(.*)$ /#!/$1 [L]

没有想法为什么它不起作用?

谢谢,马克 .

1 回答

  • 7

    你的.htaccess是这样的:

    Options +FollowSymlinks -MultiViews
    RewriteEngine on
    
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    RewriteRule ^(biography)/?$ /#!/$1 [R,L,NE,NC]
    
    RewriteCond $1 !^(images|system|files|themes|static|favicon\.ico|robots\.txt|index\.php) [NC]
    RewriteRule ^(.*)$ /index.php/$1 [L]
    

    请记住,您无法在.htaccess中检查 /#! ,因为该部分仅在浏览器中处理而不会发送到Web服务器 .

相关问题