我目前正在使用非描述性文件名(例如kejr09238u30sdkfh.jpg
)在我的网站上使用图片。出于SEO原因,我将这些图像重命名为descriptive-file-name.jpg
。
目前已重命名6张图片。
如何编写301重定向?
示例
mysite.com/images/123.jpg
重命名为 mysite.com/images/abc.jpg
你能帮帮我吗?
答案 0 :(得分:2)
使用简单的public class MyXMPP {
public MyXMPP(MyService context, String serverAdress, String logiUser,
String passwordser) {
this.serverAddress = serverAdress;
this.loginUser = logiUser;
this.passwordUser = passwordser;
this.context = context;
this.applicationContext = context;
init();
}
public static MyXMPP getInstance(MyService context, String server,String user, String pass) {
if (instance == null) {
instance = new MyXMPP(context, server, user, pass);
instanceCreated = true;
}
return instance;
}
public org.jivesoftware.smack.chat.Chat Mychat;
ChatManagerListenerImpl mChatManagerListener;
MMessageListener mMessageListener;
static {
try {
Class.forName("org.jivesoftware.smack.ReconnectionManager");
} catch (ClassNotFoundException ex) {
// problem loading reconnection manager
}
}
public void init() {
gson = new Gson();
mMessageListener = new MMessageListener(context);
mChatManagerListener = new ChatManagerListenerImpl();
initialiseConnection();
}
private void initialiseConnection() {
XMPPTCPConnectionConfiguration.Builder config = XMPPTCPConnectionConfiguration
.builder();
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
config.setServiceName(serverAddress);
config.setHost("192.168.0.101");
config.setPort(5222);
config.setDebuggerEnabled(true);
XMPPTCPConnection.setUseStreamManagementResumptiodDefault(true);
XMPPTCPConnection.setUseStreamManagementDefault(true);
connection = new XMPPTCPConnection(config.build());
XMPPConnectionListener connectionListener = new XMPPConnectionListener();
connection.addConnectionListener(connectionListener);
}
private class ChatManagerListenerImpl implements ChatManagerListener {
@Override
public void chatCreated(final org.jivesoftware.smack.chat.Chat chat,
final boolean createdLocally) {
if (!createdLocally)
chat.addMessageListener(mMessageListener);
}
}
public void sendMessage(ChatMessage chatMessage) {
String body = gson.toJson(chatMessage);
Mychat = ChatManager.getInstanceFor(connection).createChat(
chatMessage.receiver + "@"
+ context.getString(R.string.server),
mMessageListener);
chat_created = true;
final Message message = new Message();
message.setBody(body);
message.setStanzaId(chatMessage.msgid);
message.setTo(chatMessage.receiver);
message.setFrom(chatMessage.sender);
message.setType(Message.Type.chat);
Mychat.sendMessage(chatMessage.body);
}
public void sendGroupMessage(ChatMessage chatMessage) {
MultiUserChatManager manager = MultiUserChatManager.getInstanceFor(connection);
MultiUserChat multiUserChat = manager.getMultiUserChat(chatMessage.receiver);
try {
multiUserChat.join(chatMessage.sender,"12345");
// multiUserChat.addMessageListener((MessageListener) mMessageListener);
} catch (XMPPException.XMPPErrorException e) {
e.printStackTrace();
} catch (SmackException e) {
e.printStackTrace();
}
Message message = new Message(chatMessage.receiver, Message.Type.groupchat);
message.setBody(chatMessage.body);
message.setType(Message.Type.groupchat);
message.setFrom(chatMessage.sender);
message.setTo(chatMessage.receiver);
multiUserChat.sendMessage(message);
}
/* Its work good for one to one chat */
private class MMessageListener implements ChatMessageListener {
Context context;
public MMessageListener(Context c) {
this.context = c;
}
@Override
public void processMessage(final org.jivesoftware.smack.chat.Chat chat,
final Message message) {
if (message.getType() == Message.Type.chat
&& message.getBody() != null) {
Log.d("Message received",message.getBody);
}
}
}
}
命令:
redirect