使用.htaccess和symfony修改URL

时间:2012-08-24 21:25:29

标签: apache .htaccess symfony-1.4

我正在使用symtfony 1.4,我有一个名为backend的模块,其索引文件是

  

wwww.domain.com/backend.php

但是当我在浏览器上写道www.domain.com/back时,我希望将其重定向到

  

www.domain.com/backend.php

我尝试使用此规则

RewriteRule ^/back$ www.domain.com/backend.php

但它不起作用。

这是我的.htaccess

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  #RewriteCond %{REQUEST_URI} \..+$
  #RewriteCond %{REQUEST_URI} !\.html$
  #RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  RewriteRule ^/back$ www.domain.com/backend.php 

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

1 个答案:

答案 0 :(得分:0)

尝试更改:

  RewriteRule ^/back$ www.domain.com/backend.php 

  RewriteRule ^back$ http://www.domain.com/backend.php [L]