使用Wordpress忽略mod_rewrite规则

时间:2015-05-12 00:08:10

标签: apache .htaccess mod-rewrite

我正在尝试使用mod_rewrite将所有请求重定向到特定目录:

class Game extends JFrame
{

   private Map map;

   public Game()
   {

//      setLayout( null );
      setBounds( 0, 0, 500, 500 );
      setSize( 500, 500 );
      setResizable( false );
      setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

      Map map = new Map( 500, 500, 50 );
      map.displayConsole();

      add( map );
      pack();
      repaint();
      setVisible( true );
   }

   public static void main( String[] args )
   {
      // TODO Auto-generated method stub

      Game game = new Game();


   }

}

class Map extends JPanel
{

   private static int WIDTH;
   private static int HEIGHT;
   private static int ROWS;
   private static int COLS;
   private static int TILE_SIZE;
   private static int CLEAR = 0;
   private static int BLOCKED = 1;

   private static int[][] GRID;

   public Map( int w, int h, int t )
   {

      WIDTH = w;
      HEIGHT = h;
      TILE_SIZE = t;
      ROWS = HEIGHT / TILE_SIZE;
      COLS = WIDTH / TILE_SIZE;

      GRID = new int[ ROWS ][ COLS ];

      for( int row = 0; row < ROWS; row++ )
         for( int col = 0; col < COLS; col++ )
            GRID[row][col] = BLOCKED;

      randomMap();
   }

   public void randomMap()
   {
      int row = 0;
      int col = 0;
      int turn;

      Random rand = new Random();

      GRID[row][col] = CLEAR;

      do {
         turn = rand.nextInt( 2 ) + 1;
         if( turn == 1 )
            row++;
         else
            col++;
         GRID[row][col] = CLEAR;
      } while( row < ROWS - 1 && col < COLS - 1 );

      if( row == ROWS - 1 )
         for( int i = col; i < COLS; i++ )
            GRID[row][i] = CLEAR;
      else
         for( int i = row; i < ROWS; i++ )
            GRID[i][col] = CLEAR;

   }

   @Override
   public Dimension preferredSize()
   {
//      return super.preferredSize(); //To change body of generated methods, choose Tools | 
      return new Dimension( WIDTH, HEIGHT );
   }

   @Override
   public Dimension minimumSize()
   {
      return preferredSize();
   }




   public void paintComponent( Graphics g )
   {

      super.paintComponent( g );
      Graphics2D g2d = (Graphics2D) g;

      for( int row = 0; row < ROWS; row++ )
         for( int col = 0; col < COLS; col++ )
            if( GRID[row][col] == 1 ) {
               g2d.setColor( Color.BLACK );
               g2d.fillRect( row * TILE_SIZE, col * TILE_SIZE,
                       TILE_SIZE, TILE_SIZE );
            } else {
               g2d.setColor( Color.WHITE );
               g2d.fillRect( row * TILE_SIZE, col * TILE_SIZE,
                       TILE_SIZE, TILE_SIZE );
            }
   }

   public void displayConsole()
   {

      for( int row = 0; row < ROWS; row++ ) {
         for( int col = 0; col < COLS; col++ )
            System.out.print( GRID[row][col] + "   " );
         System.out.println( "" );
         System.out.println( "" );
      }
   }
}

从这里开始,我计划获取请求的URI并提供相应的页面。

但似乎这条规则甚至没有被触发。

由于

1 个答案:

答案 0 :(得分:0)

通过htaccess文件中的重写规则发送的URI删除了前导斜杠,因此无法匹配/about/,您需要删除前导斜杠:

RewriteEngine On
RewriteRle ^about/(.*)$ /wp-content/themes/twentyfiteen/test.php [L]