htaccess的重写规则不是让我真正的存取权限目录 [英] htaccess RewriteRule not letting me acces REAL directories

查看:103
本文介绍了htaccess的重写规则不是让我真正的存取权限目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的.htaccess文件

This is my .htaccess file

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# Force add trainling slash
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ http://foo.bar/$1/ [R=301,L]

# Prepent www if not exist in URI
RewriteCond %{HTTP_HOST} ^foo\.bar$
RewriteRule (.*) http://www.foo.bar/$1 [R=301,L]

# If path is not a directory or file then apply RewriteRule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite for profile view
RewriteRule ^([^/]+)/?$ profile.php?user=$1 [NC,L]

# Rewrite for page view
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ account.php?type=$1&user=$2&page=$3 [QSA,L]

# Condition to ignore regular links
RewriteRule ^library/templates/([^/]+)/([^/]+)/([^/]+)/?$ library/templates/$1/$2/$3 [QSA,L]

# Rewrite for dynamic page settings
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ account.php?type=$1&user=$2&page=$3&$4=$5 [QSA,L]

# Rewrite for account view
RewriteRule ^([^/]+)/([^/]+)/?$ account.php?type=$1&user=$2 [QSA,L]

# Rewrite for site default resources location
RewriteRule ^([^/]+)/([^/]+)/theme/s/([^/]+)/([^/]+)/([^/]+)/?$ library/themes/site/$3/$4/$5 [QSA,L]

我知道这有点不走对此最好的方式,感觉就像有太多的冗余,但我不是专家,但它为我工作。如果任何人都可以给我就如何使这更有效的我会强烈AP preciate吧。

I know this is kinda not the best way to go about this, feels like there is too much redundancy but I'm no expert but its working for me. If anyone can give me advise on how to make this more efficient I would highly appreciate it.

好了,所以我的问题是,我在

Ok so my problem is that I have a real directory at

www.foo.bar/path/to/real/dir

和我要访问一个文件,在该目录中,但我重写规则是不让进入该目录,除非我提出一个新的重写规则重定向我的网址给自己。

and I want to access a file in that directory, but my rewrite rules aren't letting access that directory unless I make a new rewrite rule redirecting my url to itself.

推荐答案

检查符号链接的文件和目录,以及(如你的第一条规则):

Check for files symlinks and directories as well (as your first rule):

RewriteCond %{REQUEST_FILENAME} -f [NC,OR]
RewriteCond %{REQUEST_FILENAME} -d [NC,OR]
RewriteCond %{REQUEST_FILENAME} -l [NC]
RewriteRule .* - [L]

这篇关于htaccess的重写规则不是让我真正的存取权限目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆