htaccess文件无法正确重写

时间:2015-11-20 12:59:28

标签: .htaccess mod-rewrite

我在使用重写规则的.htaccess中遇到了问题。 这是我的.htaccess:

public class ConnectThread extends Thread{
    private  BluetoothSocket mmSocket=null;
                public  static final UUID MY_UUID = UUID.fromString("6983e974-9696-4547-afc2-143235069a79");
                 @Override
                public void run() {
                    // TODO Auto-generated method stub
                    super.run();
                    // Get a BluetoothSocket to connect with the given BluetoothDevice

                    BluetoothDevice bluetoothdevice=BluetoothConnection.btAdapter.getRemoteDevice("14:F6:5A:63:0F:8E");
                    try {
                        BluetoothSocket socket=bluetoothdevice.createRfcommSocketToServiceRecord(ConnectThread.MY_UUID);
                        BluetoothAdapter adapter=BluetoothAdapter.getDefaultAdapter();
                        if(adapter!=null)
                        {
                        adapter.cancelDiscovery();  
                        }

                        if(socket!=null)
                        {

                            socket.connect();
                            Log.i("***Socket Connection Successful**", "Socket Connection Successful");
                        }
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        Log.e("***Error**","Socket Connection failed");
                        e.printStackTrace();
                    }

                }
     }

错误在底部两行,任何人都去/ user / foo 会看到去/ user的结果吗?u = foo。

2 个答案:

答案 0 :(得分:1)

您可以使用:

RewriteEngine On

RewriteRule ^user/(.+)/?$ user.php?u=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

答案 1 :(得分:1)

试试这个:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_FILENAME}.php [NC,L]
RewriteRule ^/?user/([\w-]+)/?$ user.php?u=$1 [L]