My website is 'http://www.yx86911.com/Defaul...' or 'http://www.yx86911.com/Defaul...' How to remove the following to get 'http:// www.yx86911.com'
Thank you for your answers
Sorry for not making it clear, the folder still needs to be left.
For example, http://www.yx86911.com/xxx/in... To get http://www.yx86911.com/xxx/
高洛峰2017-06-12 09:30:55
var url = 'http://www.yx86911.com/xxx/index.html'
url.substr(0, url.lastIndexOf('/'))
黄舟2017-06-12 09:30:55
I think what he means is to use regular expressions to match addresses.
Sir, do you want to match only the first folder or all folders except files?
var a = 'http://www.yx86911.com/xxx/555/index.html';
a.match(/http:\/\/.+com\/(.+?\/)?/)//匹配出"http://www.yx86911.com/xxx/"
a.match(/http:\/\/.+com\/(.+\/)?/)//匹配出"http://www.yx86911.com/xxx/555/"
漂亮男人2017-06-12 09:30:55
You can just change the file name to index.aspx. The default main file of the website is index
学习ing2017-06-12 09:30:55
This is usually configured in Apache, IIS or Nginx. The configuration method of Apache is:
Enable the mod_rewrite module
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
1
Change AllowOverride None
to AllowOverride All
PHP中文网2017-06-12 09:30:55
var url = new URL("http://www.yx86911.com/123/");
console.log(url.origin+url.pathname.replace(/[\/]*$/,''))