.htaccess 301重定向并删除page.php

时间:2017-07-07 17:22:57

标签: php .htaccess redirect

所以我的问题是我在子目录中运行并且有几个问题......

  1. 当我添加301重定向时,我收到500错误
  2. 我无法从网址(http://174.136.15.245/~clubz/test/page/about-club-z-tutoring-test
  3. 中删除“页面”

    这是我的代码:

    <IfModule mod_rewrite.c>
        Options +FollowSymLinks
        RewriteEngine On
        RewriteCond %{HTTPS} !=on
        # RewriteRule (.*) http://174.136.15.245/~clubztutors/test/ [R,L]
    
        RewriteBase /~clubz/test/
    
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        # RewriteRule ^(.*)$ page.php?/$1 [R=301, L]
        # RewriteRule ^page.php?p=$1 page/([^/.]+)/?$ [R=301, L]
        # This works but add "page" directory
        RewriteRule ^page/([^/.]+)/?$ page.php?p=$1 [L]
    </IfModule>
    

    我确实在这里查看了其他一些解决方案,但我仍然无法完全按照我需要的方式运行。任何见解都将不胜感激。

1 个答案:

答案 0 :(得分:0)

累积奖金!好吧,至少从URL中删除页面:

'use strict';
const AWS = require('aws-sdk');
const moment = require('moment');

exports.postArchive = (event, context, callback) => {
    const parsedInput = JSON.parse(event.body);
    const stepInput = JSON.stringify({ "thingId": parsedInput.thingId });
    const rightNow = moment().format('YYYYMMDD-hhmmss');
    const params = {
        stateMachineArn: 'arn:aws:states:us-east-1:ACCOUNT_ID:stateMachine:create-archive',
        input: stepInput,
        name: `ArchiveAt${rightNow}`
    };
    console.log(JSON.stringify(params));
    const stepfunctions = new AWS.StepFunctions({apiVersion: '2016-11-23'});

    stepfunctions.startExecution(params, function (err, data) {
        if (err) {
            console.log(err, err.stack);
            callback(err, null);
            return;
        }
        const response = {
            statusCode: 200,
            headers: {
                "Content-Type": "application/json"
            },
            body: JSON.stringify({
                message: "State Machine started successfully.",
                result: data
            })
        };
        callback(null, response);
     });
};

重定向仍然不起作用,但它会很好。现在,我将继续这样做。