简体   繁体   English

如何强制网站URL与域地址相同

[英]How to force website URL to remain the same as the domain's address

Here is what I have got: 这是我得到的:

  • A free hosting with FTP access ( www.example.com ) 具有FTP访问权限的免费主机( 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/ ) 一个基于Wordpress的网站,其Wordpress实例安装在public_html根目录的子文件夹( 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. 地址为www.mydomain.net的付费域,已使用其DNS地址寄存在www.example.com上

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. 我希望能够在浏览器的地址栏中输入我的域地址,并访问www.example.com/wpsite,而无需任何可见的重定向形式。 I want the browser's address bar to contain www.mydomain.net , with the plausible addition of /wpsite/ . 我希望浏览器的地址栏包含www.mydomain.net ,并加上/ 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. 我设法达到所需效果的最接近方法是使用php的标头位置脚本,但这会修改​​地址。 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. 发生的是,当我尝试访问www.mydomain.net时,我立即被重定向到www.example.com/wpsite ,并且虽然我希望页面正确加载,但是显然,我希望地址保持与域的地址。

And here is what I have tried to no avail: 这是我试图徒劳的:

  • php's header location script php的标头位置脚本
  • modifying the .htaccess files - ended up causing a redirection error 修改.htaccess文件-最终导致重定向错误
  • jQuery/JavaScript window.history.pushstate - it just didn't work jQuery / JavaScript window.history.pushstate-只是不起作用

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? 还是将Wordpress实例从/ wpsite /子文件夹移到要删除它的根目录中?

I would be very grateful for an answer - I did not manage to find it yet, and I am getting truly desperate. 我非常感谢您的回答-我还没有找到答案,而我正变得非常绝望。

just take out a index.php file from "wpsite" to root directory. 只需从“ wpsite”到根目录中取出一个index.php文件。

and edit the index.php file and change this line of code. 并编辑index.php文件并更改此代码行。

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 然后打开数据库并找到wp_option表并找到一个条目

option_name = home

replace option_value with your domain. 用您的域替换option_value

then run i hope this is working. 然后运行,我希望这是可行的。 reference from this site 来自本网站的参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM