How to force website URL to remain the same as the

2019-09-02 20:49发布

问题:

Here is what I have got:

  • A free hosting with FTP access (www.example.com)
  • A Wordpress-based website, with the instance of the Wordpress installed in a sub-folder of the public_html root directory (www.example.com/wpsite/)
  • A paid domain with an address of www.mydomain.net, which has been parked on the www.example.com using their DNS addresses.

The problem I have is as follows:

I want to be able to write my domain's address in the browser's address bar and reach www.example.com/wpsite without any visible form of redirection. I want the browser's address bar to contain www.mydomain.net, with the plausible addition of /wpsite/.

The closest I have managed to get to the desired effect was by using php's header location script, but that modifies the address. What happens is, as soon as I try to access www.mydomain.net I am being redirected to www.example.com/wpsite, and while I want the page to load correctly, obviously, I want the address to remain the same as the domain's address.

And here is what I have tried to no avail:

  • php's header location script
  • modifying the .htaccess files - ended up causing a redirection error
  • jQuery/JavaScript window.history.pushstate - it just didn't work

What would be the best way to achieve my goal? Is it one of the above? Or is moving the Wordpress instance from the /wpsite/ subfolder into the root directory going to cut it?

I would be very grateful for an answer - I did not manage to find it yet, and I am getting truly desperate.

回答1:

just take out a index.php file from "wpsite" to root directory.

and edit the index.php file and change this line of code.

require( dirname( __FILE__ ) . '/wp-blog-header.php' );

change with

require( dirname( __FILE__ ) . '/wpsite/wp-blog-header.php' );

then open your database and find the wp_option table and find one entry

option_name = home

replace option_value with your domain.

then run i hope this is working. reference from this site