好的,我有几个关于htaccess的问题。
首先,我希望website/index.php
成为website/
,即使有人在index.php
输入结尾。
其次,我想删除.php
即使您输入/
并在website/about-us.php
website/about-us/
添加RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
到/
。
我添加了这个以删除末尾的扩展名:
index.php
除了不是100%确定如何添加(function() {
angular
.module('myapp')
.run(['$httpBackend', function($httpBackend) {
$httpBackend.whenGET(/.*\/api\/ratings\/\?.*/).respond(function(method, url) {
var params = matchParams(url.split('?')[1]);
var list = findRatings(ratings, params);
return createPageResponse(list, params.page, params.size);
});
}]
})();
之外,我发现将class A(object):
@classmethod
def c(cls, x, y):
print('cls:{}, x:{}, y:{}'.format(cls, x, y))
class B(A):
def c(self, y):
super(B, self).c(x = 'fixed', y = y)
class C(A):
def c(self, x):
super(C, self).c(x = x, y = 'fixed')
b = B()
c = C()
>>>
>>> b.c(4)
cls:<class '__main__.B'>, x:fixed, y:4
>>> c.c(4)
cls:<class '__main__.C'>, x:4, y:fixed
>>>
更改为网址根目录的所有内容对我来说都不起作用。
答案 0 :(得分:0)
试试这个
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
答案 1 :(得分:0)
尝试此规则,
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^index.php$ www.{HTTP_HOST}/ [R=301]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]