htaccess替换域并添加语言

时间:2017-05-10 05:19:06

标签: php .htaccess redirect

我尝试了一些方法,但我需要一些关于重定向规则的帮助:(

我需要的是

domainA.com/pagename.php 重定向至 domainB.com/pagename.php?lang=EN

domainA.com/directory/pagename.php 重定向至 domainB.com/directory/pagename.php?lang=EN

我尝试过这样的事情

package vehicalservice;

import com.jfoenix.controls.JFXProgressBar;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * FXML Controller class
 *
 * @author lahir
 */
public class SplashNewController implements Initializable {

    @FXML
    private StackPane stackPane;
    @FXML
    private AnchorPane anchorPane;
    @FXML
    private JFXProgressBar pbarLoad;
    @FXML
    private Label lblLoad = new Label();

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        new SplashScreen().start();
    }    

    class SplashScreen extends Thread{
        @Override
        public void run(){
            try {

                for (int i = 0; i <=100;i++){
                        Thread.sleep(40); 
                        if(i<=30){
                           lblLoad.setText("Initilizing Components...");
                       }else if(i<=50){

                           lblLoad.setText("Initializing Database Connection...");
                           //new mainCLass().openDB();
                       }else if(i<=80){
                           lblLoad.setText("Initializing User Interface...");                           
                       }else{
                           lblLoad.setText("Please wait...");         
                       }
                }
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        Parent root=null;
                        try {

                            root = FXMLLoader.load(getClass().getResource("Login.fxml"));
                            Scene scene = new Scene(root);
                            Stage stage = new Stage();
                            stage.initStyle(StageStyle.UNDECORATED);
                            stage.setScene(scene);
                            stage.show();

                            stackPane.getScene().getWindow().hide();
                        } catch (IOException ex) {
                            //Logger.getLogger(SplashController.class.getName()).log(Level.SEVERE, null, ex);
                        }                       
                    }
                });

            } catch (InterruptedException ex) {
                //Logger.getLogger(SplashController.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

}

并且

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^domainA.com
RewriteRule ^(.*) http://domainB.com/$1?lang=EN [P]  

但它不起作用。

2 个答案:

答案 0 :(得分:0)

你可以尝试这样的事吗,

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^pagename.php$ http://domainB.com/pagename.php?lang=EN [R=301]            
    RewriteRule ^directory/pagename.php$ http://domainB.com/directory/pagename.php?lang=EN[R=301]
</IfModule>

答案 1 :(得分:0)

尝试以下,

RewriteEngine On
RewriteRule ^(directory)?/([^/]+)$ http://domainB.com/$2?lang=EN [R=301,L]