How change back url of your site in wordpress - wordpress

I accidentally added www before url of my local running site for some plugin. than I couldn't access to site again because obviously my local server which is open server don't have www prefix before main path. So I changed back both in my wp-config.php and even in mySql database. In bot places they show the url path without www , but now when I press my site name in admin part its again add back this www so in result browser shows site not found. Can I somehow get rid of www from the path? Thanks

If you have made absolutely sure that ALL domain/URL related records in the database are updated so that there is no www prefix anywhere (especially the wp_options table), the problem most likely lies with the .htaccess file.
For a quick test, find the file called .htaccess in the web root folder of the site and just rename it and then try. If that works, look for something like the following in the .htaccess file:
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
If you find this, change it as follows:
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Finally, change the file name back to .htaccess and it should work fine.
Edit: In some cases, it may be necessary to clear browser cache/cookies and/or restart the browser/reboot for the changes to take effect.

Related

Wordpress page not taking precedence over server directory

On my wordpress site, I have a page mysite.com/download. On the same server I have a directory named download, where I store files which I need to provide on download page. So the problem is that when someone tries to access mysite.com/download, he's taken to the directory instead of the page. I have turned off the directory access for now, so it currently displays no permission to access. I want wordpress to display the page instead of the directory. I am not sure if it's a problem with the server or wordpress. I hope someone can clarify.
Try to put a redirection rule to your download.php file like this using .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/download.php$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /download.php [L,R=302]

Moving WordPress from subdirectory to new domain

I have a WordPress site stored and served from in a subdirectory: eg https://example.com/en/
We now need to serve it from the root of a new domain eg https://exampletwo.com/, ideally without moving the installation. The domain is already setup as a parked domain on the cpanel and serves the WordPress site correctly.
Changing the siteurl and homeurl automatically redirects https://example.com/en/ to the new location https://exampletwo.com to the correct location and works fine as expected.
The problem is with external links:
https://example.com/en/ now returns a WordPress 404 error. Setting up a page called /en/ putting a redirect to https://exampletwo.com/ works fine. A bit clumsy but works for now.
However they also used to have pages like
https://example.com/en/contact and these return server 404 errors outside of WordPress, i.e.:
The requested URL /index.php was not found on this server.
I'm trying to avoid physically moving the WordPress installation. I'm guessing that when making a request to the /en/ directory, it's actually looking for resources in the /en/en/ directory.
Is it possible to accomplish this using .htaccess / WordPress or some other method or am I best to move the installation to a new location
Thanks for any thoughts
This would be the .htaccess code you'd need in the example.com/en/ folder to redirect everything to the exampletwo.com domain. Again, it would go in the /en/ folder and not the root folder for example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://exampletwo.com/$1 [L,R=301,NC]

How to force Wordpress in subdirectory to use correct url after domain change

I have two Wordpress sites, one living in the root directory of my server, one living in a directory. Let's call them:
www.domain.com and www.domain.com/folder/
This worked fine until now, when I needed to change my domain and server. I moved my files from one server to the other, got everything running with the new domain on the new server, and then "parked" the old domain on the new server via cPanel, setting up the following .htaccess code in the root directory to handle traffic to the old domain:
RewriteCond %{HTTP_HOST} ^domain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301,NC]
This appears to work perfectly for the "main" wordpress install, BUT, while visiting URLs for the Wordpress site in the subdirectory produce the correct results, they display the OLD url:
So, for example, if I visit:
http://www.domain.com/folder/page/
I see the content for:
http://www.newdomain.com/folder/page/ (eg. all the links etc. are correct)
But the URL still displays as http://www.domain.com/folder/page/
Nothing I do with .htaccess, etc. seems to change this. How can I force http://www.domain.com/folder/page/ to fully redirect to http://www.newdomain.com/folder/page/ not just show the content for it?

Fishpig Wordpress Magento - http://example.com/blog resolves to www.example.com rather than www.example.com/blog

I have a working Fishpig Wordpress Magento instance on a production server.
All the green ticks show it has succesfully configured and when visiting
http://www.example.com/blog
it works. However when I try and and visit
http://example.com/blog
it sends me back to the magento home page at www.example.com .
I have tried setting the url in wordpress to both http://example.com/blog and http://www.example.com/blog but in both situations it always sends me to the home page at site.com.
This is a concern because most experienced web users will not type www when trying to access a location.
My htaccess is as generated by Wordpress and looks like
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
#wp generated
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Please not the wordpress site files are located at site.com/wp and it is the fishpig extension which arranges the direct from the non existent /blog path.
First of all, to start of, one way to resolve the issue is to simply make your Magento website DEFAULT to not have the www. in the url.
In Magento, go to System > Configuration > Web.
In the "Secure" and "Unsecure" tabs, find "Base URL."
The value should look something like this:
http://www.site.com/
Replace ALL references to the domain so it shows:
http://site.com/
Unfortunately, there may be a lot of appearances of it throughout the site. You'll need to do the same thing elsewhere on the server.
If you really want your site/blog to say www., though, you'll have to properly forward the .htaccess file in Magento. I'm not too keen on how Magento's .htaccess file works, but I do know how to forward a url and keep all of its additional pages as well (however, Magento's setup may interfere).
The code should look something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteRule ^(.*)$ http://www.site.com$1 [R=301,L]
Again, I don't know how well this will work with Magento's set up, but I've successfully used the above code to redirect url's to the correct url I want. That code above was actually used on a wordpress site, though.
Check for Rewrite rules in Magento's .htaccess file and try putting this above it. Be careful, though; it is VERY easy to cause 500 internal server errors if you mess up the .htaccess file, so always keep a backup.
Try this out and I hope it helps.

Limit web folder access to specific URL

I am hosting two different websites using one hosting package.
My initial website is self-built and runs from the public_html directory of my host let's call this 'http://www.website1.co.uk'
I also have a Word Press blog running in a folder under the public_html - so '/folder_2', let's call this 'http://www.website2.co.uk' - this URL currently points to '/folder_2' and will load the blog when entered in to a browser.
At the moment the blog is also accessible by entering 'http://www.website1.co.uk/folder_2/'.
I would like to be able to limit access to 'folder_2' to just 'website2.co.uk' - preventing somebody typing in the 'website1.co.uk/folder_2' path and being able to view the blog.
What's the best way to achieve this, bearing in mind the folder in question is running a Word Press blog.
Try adding this in your .htaccess file in folder_2
RewriteEngine On
RewriteCond %{http_host} !website2.co.uk
RewriteRule .* http://website2.co.uk
that would redirect anyone who goes to website1.co.uk/folder_2 to website2.co.uk, but if you just want them hit a 404 put this in .htaccess instead
RewriteEngine On
RewriteCond %{http_host} !website2.co.uk
RewriteRule .* - [R=404,L]
1# move folder_2 out of public_html(you really should do that).
2# rewrite all request of 'http://www.website1.co.uk/folder_2/' to 404 in htaccess
Check below link:
Redirection Subfolder Htaccess

Resources