Php url重写和google robots txt
我使用php slim框架,url重写这里是我的主机真实文件结构:Php url重写和google robots txt,php,security,seo,rewrite,robots.txt,Php,Security,Seo,Rewrite,Robots.txt,我使用php slim框架,url重写这里是我的主机真实文件结构: 像大多数框架一样,全部重写为index.php /.htaccess /assets /index.php /phpinfo.php /robots.txt /usr /controller /model ... 这是我的路由器 $app->get('/backstage', $authenticate(), function () use ($uri, $app) {...}); $app-&g
像大多数框架一样,全部重写为index.php
/.htaccess
/assets
/index.php
/phpinfo.php
/robots.txt
/usr
/controller
/model
...
这是我的路由器
$app->get('/backstage', $authenticate(), function () use ($uri, $app) {...});
$app->get('/api', $authenticate(), function () use ($uri, $app) {...});
$app->get('/', function () use ($uri, $app) {...});
$app->get('/article', function () use ($uri, $app) {...});
如何在我的路径中禁用/backstage
,/api
,以及真实文件路径/phpin.php
,/usr
,并接受路由器中的
/
,/article
我搞不清楚我应该填写路由器路径还是真正的文件路径?因为实际文件路径不存在/article
这是我试过的
User-agent: *
Disallow: /backstage/
Disallow: /phpinfo.php
首先(假设您使用apache),您需要确保.htaccess文件正确地将请求指向路由器文件
---begin.htaccess代码段---
//---end-slim-router.php---
<IfModule mod_rewrite.c>
RewriteEngine On
## direct all requests to Slim router
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ slim-router.php [QSA,L]
</IfModule>
$app = new \Slim\Slim();
$defview = new \Slim\View();
$defview->setTemplatesDirectory(realpath(__DIR__).'/templates');
$app->get(
'/article',
function () use ($app) {
global $defview;
//show the contents of 'templates/article.php', passing optional data to the template file:
$app->view($defview)->display(
'article.php',
array(
'data_one'=>'one',
'data_two'=>2,
'three'=>'3',
)
);
}
);