Wordpress page not taking precedence over server directory - wordpress

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]

Related

How change back url of your site in 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.

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

Wordpress installed in root folder, subdomain now not working, GoDaddy host

please forgive me for being a complete beginner at this, I'd rather not have to try to deal with this myself but as GoDaddy support have not replied after 2 days I'm going to have to. I think my problem is the same as the one above, but I'm not 100% sure, so I'm reposting it, I'm not really confident enough to attempt to try the fixes I've seen here so I need someone to give me baby instructions?
Our original website (www.mwpics.com.au) was built in Dreamweaver etc, recently we created a new website in Wordpress, in a subdomain, then migrated it over to the root folder where it is now operating fine. I also moved the files for the old website into another directory which I called 'old', so they're all still there.
The problem is that I have a subdomain set up - which is still showing as set up in the control panel on godaddy the url is www.mwpics.com.au/clients and it is at www.clients.mwpics.com.au. This directory contains loads of other directories, each of which is password protected by .htaccess files and which our clients access directly (not through the site) to download their finished work. The test one and the one for random clients is www.mwpics.com.au/clients/temp - username and password both temp (the usernames are all the same as the directory names).
Since the WP install to the root directory the /clients extension no longer works (it should bring up an information page which is an .html index page in the directory) and the /clients/name extensions no longer works - it goes back to the wp site with a 'not found' error message. Strangely it does bring up the box for the username and password, but when you enter it it just goes back to the 'not found' message.
Someone told me it was the .htaccess file - so as an experiment, I renamed the .htaccess file in the root directory and then copied the .htaccess file from the old root files into the root directory, eureka! It worked - and also the WP site opened to the home page... but bummer - the /pages in the WP site now no longer worked! But at least I know the source of the problem.
So I switched it back and this is the status quo - I have no idea how to fix this, and with everyone back at work tomorrow, clients are going to want to start downloading their stuff...
Can anyone help me? I'm starting to panic a bit
you only have to exclude the clients subfolder in your wordpress .htaccess - see .htaccess & Wordpress: Exclude folder from RewriteRule for a detailed description
this should work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/clients.*
RewriteCond %{SERVER_NAME} !clients\.yourdomain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
short: it simply skips the wordpress rewrite rule if the reqest uri starts with /clients or the domain name is clients.yourdomain.com
be aware though, that as soon as you update your wordpress permalink settings, this rule will be overwritten by wordpress ...
Try adding the following at the top of your root directory's .htaccess file, before the WP code block:
<IfModule mod_rewrite.c>
# fix rewrite for GoDaddy
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} clients.mwpics.com.au$ [NC,OR] # ignore subdomain
RewriteCond %{REQUEST_FILENAME} -d [NC] # ignore directories
RewriteRule .* - [L]
</IfModule>

How to set CodeIgniter to ignore Wordpress folder?

I built a website with CodeIgniter last year www.example.com, and client wanted Wordpress Blog last week. I built the blog and uploaded to www.example.com/blog
Now when I click any link on wordpress it gives error as below :/
http://www.example.com/blog/category/one-last-category/
An Error Was Encountered
Unable to
load your default controller. Please
make sure the controller specified in
your Routes.php file is valid.
How can I set Codeigniter to ignore Wordpress folder?
Appreciate helps!!!
You'll want to do this with an .htaccess file (assuming your web server supports it.) For example, in the DocumentRoot of my Codeigniter site I have an .htaccess file which contains:
RewriteEngine on
RewriteCond $1 !^(index\.php|static|user_guide|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
This allows me to still access static files and the CI user guide. In your case the RewriteCond would be something like:
RewriteCond $1 !^(index\.php|blog)

Using .htaccess to redirect if file isn't found with Wordpress

I have an issue where we are merging a website with Wordpress. The website has a ton of news stories in a "/news" directory that we need to keep. When we add the CMS at say "/wordpress" we can set the base URL to the root of the directory so when we make a new post in the category "news", the link for it is "/news/this-is-the-post-title", except the REAL location is "/wordpress/news/this-is-the-post-title". So my issue is that we want to keep all news stories at the "/news" URL, and in my head we just need the .htaccess to say "if the requested URL doesn't exist in the /news directory, try /wordpress/news", and of course if Wordpress doesn't find anything, it can 404. Hope this makes sense, thank you!
I don't fully understand how the original news stories are held. But, if they are grabbed with PHP then you should be able to redirect to /wordpress/news/post-title if it doesn't exist.
On the other hand, if the news stories are static files you can check for them with .htaccess and make sure the file exists on the server.
# Goes in the "news" directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news
# These make sure the file or directory doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect to /wordpress/news/whatever-entered-goes-here
RewriteRule ^(.*)$ /wordpress/news/$1 [L]
</IfModule>
Reference: http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
If you only use WordPress and static pre-existing directories and files (and not another CMS, next to WordPress), you can probably just follow the directions on giving WordPress its own directory. All WordPress files go to wordpress/, only the index.php and .htaccess are copied back to the root directory. The standard .htaccess from WordPress already has the two RewriteCond rules that check for existing files, so if the request is for news/happy-2010.html and this file already exists, your server will just serve this and not start WordPress.

Resources