我有一个瘦框架项目,我的文件夹结构如下:
root web directory
--project
-----api
-----vendor
-----index.php
-----.htaccess
现在,我的问题是我想从我的API网址中删除index.php,以便我可以使用http://127.0.0.1/project/api/test而不是http://127.0.0.1/project/api/index.php/test。我的.htaccess看起来像这样,但不起作用: RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
答案 0 :(得分:0)
这应该适合你。
RewriteEngine On
RewriteRule ^api/([^/]*)$ /project/api/index.php?value=$1 [L]
答案 1 :(得分:0)
在Root/.htaccess
文件
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^project/api/(.*)/?$ /project/api/index.php/$1 [QSA,NC,L]
答案 2 :(得分:0)
谢谢你们,但这对我有用:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
希望它能帮助别人......
答案 3 :(得分:0)
我执行了以下步骤,使其在Ubuntu独立服务器上运行。
第1步 - 您必须启用重写mod
https://xxxxxx.azurewebsites.net/Account/Oauth
第2步 - 确保/etc/apache2/apache2.conf中的apache设置如下:
adminSchema.pre('save', function(next) {
var user = this;
// only hash the password if it has been modified (or is new)
if (!user.isModified('password')) {
return next();
}
// password changed so we need to hash it (generate a salt)
bcrypt.genSalt(SALT_WORK_FACTOR, function(err, salt) {
if (err) {
return next(err);
}else{
// hash the password using our new salt
bcrypt.hash(user.password, salt, function(err, hash) {
if (err) { return next(err); }
// override the cleartext password with the hashed one
user.password = hash;
next();
});
}
});
});
adminSchema.methods.comparePassword = function(password, cb) {
console.log('comparing password');
bcrypt.compare(password, this.password, function(err, isMatch) {
cb(err, isMatch);
});
};
确保全部覆盖应全部
第3步 - 使用以下
创建.htaccess文件a2enmod rewrite