htaccess url指向子文件夹

时间:2014-02-14 01:27:27

标签: apache .htaccess

我的根子文件夹就像这样

Root(www.example.co.uk)

  • my_framework
  • my_images

我想如果用户请求example.com指向example.com/my_framework(使用cakephp),但在url中显示www.example.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.co.uk$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.co.uk$
RewriteCond %{REQUEST_URI} !example.co.uk/
RewriteRule ^(.*) http://www.example.co.uk/my_framework/$1 [R=301,L]

并且当用户想要查看某些页面中的图像时,图像位于my_images文件夹中,以便他们可以访问此图像。

1 个答案:

答案 0 :(得分:1)

您可以尝试以下规则:

RewriteEngine on

#this OR and third line accept www from url
RewriteCond %{HTTP_HOST} ^(www\.)?glamestates.co.uk$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!my_framework/).*)$ /my_framework/$1 [NC,L]