我在访问索引文件的一个小问题,当重写引擎删除的.php和.html ...
I have a little problem accessing index files when rewrite engine removes .php and .html...
我有一个指数的public_html /用户/用户名/的index.php 但它引发了我到错误,当我试图访问网页或者
I have an index in "public_html/user/username/index.php" But it throws me to error page when I'm trying to access either
mydomain.com/user/username 或
mydomain.com/user/username/index 或
mydomain.com/user/username/index.php
当我试图达到从文件夹中的public_html文件夹中的所有文件让我们说
When I'm trying to reach any file from folder in public_html folder let's say
的public_html /用户/ username.php == mydomain.com/user/username < - 工程
public_html/user/username.php == mydomain.com/user/username <-- WORKS
这是怎么回事?
我的.htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]
重写引擎已经打开,一切都完美地工作... 的
推荐答案
您应该将这些etenstions前检查的PHP和html文件presence:
You should check for presence of php and html files before adding those etenstions:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+)/?$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^.]+)/?$ $1.html [L]
相关推荐
最新文章