wordpress home page use from different directory - wordpress

I have wordpress installed on my root folder directory files are like public_html/wp-admin, public_html/wp-content etc..
I want it when my site "www.example.com" is visited it will read another folder in the subdirectory eg (public_html/showhomepage)
where showhomepage has a static index.html with css, images etc
Is this possible?

In your wordpress/index.php:
header('Location: showhomepage');
Or you can set up a rewrite rule in your .htaccess file:
RewriteCond %{DOCUMENT_ROOT}/index.php !-f
RewriteRule . /showhomepage [L]
Or something along those lines. Apache has good on mod_rewrite and there's plenty of supporting sites to make some of the explanations more clear.
I may be mistaken but, that redirects requests to your site to showhomepage. I'm not an expert at rewrite rules but I think you can suppress the path with REQUEST_FILENAME in your rewrite conditions.

Related

Elgg with within subdirectory that is not executed by elgg

I have website that run elgg in root directory.
But I want into subdirectory that is located within elgg put wordpress site.
Example:
www.mysite.com - elgg,
www.mysite.com/wp - wordpress
Yes, and I don't need any kind of integration between them (no bridge)
Just to elgg not to execute this folder
So I need for directory www.mysite.com/wp different rules than for rest site.
I tried changing .htaccess file for www.mysite.com/wp directory, but I think it's wrong way.
It is working only for simple .php files, but wordpress is more complex and after long period of loading It show elgg "nothing found" site loaded.
Please don't ask change site structure, it is already set. And wordpress in subdirectory also has it's reasons.
I know there must be easy solution for this issue like elgg plugin for subdirectories, but problem is that web is flooded with topics about installing elgg in subdirectory and I can't find solution.
You can use a rewrite rule that uses ^$ to represent the root and rewrite that to your /wp directory, and write this just above index.php like this:
RewriteEngine On
RewriteRule ^wp(.*)$ /wp [L]
RewriteRule ^(.*)$ index.php?__elgg_uri=$1 [QSA,L]

Removing Wordpress directory name from certain URLs using .htaccess

So I have one Wordpress install in a sub-directory. (www.mysite.com/wp/)
What I need is for certain pages to remove the WP directory name from the URL.
so 'www.mysite.com/wp/careers' needs to be -> 'www.mysite.com/careers'
I have an .htaccess in the root directory and in the wp directory. I've gotten some of my rules to work when permalinks are disabled in WP, but when those are enabled (which they need to be) the WP .htaccess overrides any rules I have in the root.
Is there any way to have 2 htaccess co-exist in this manner? Sorry I haven't messed with wordpress and apache very much.
Any input is greatly appreciated.
**So I finally got this working, it was just a matter of like you said formatting redirect URL so wordpress likes it.
So in my root htaccess file : for this url mysite.com/careers
RewriteRule ^careers/?$ wp/index.php?pagename=careers [L]
And voila and it started working just fine.
Yes, you can have rules in both htaccess files but it's going to be tricky as wordpress has specific ways that it will expect URLs to look.
In the wordpress htaccess file, above any wordpress related rules, add:
RewriteCond %{THE_REQUEST} \ /+wp/careers
RewriteRule ^ /careers [L,R]
then in the htaccess file in the document root add:
RewriteRule ^careers$ /wp/careers [L]
But again, depending on what wordpress expects the "careers" URL to look like, this may not solve your problem.

Have WordPress with a different index file for testing

A site I'm designing a website for was built with static HTML files. I'm converting it to WordPress but I need the old site to still function while WordPress is installed in the same directory (e.g. have index.html be the default one and then have WordPress be something like indexNew.php)
So they go to http://domain.com/indexNew.php to see updates to the new website until it's finished.
How would I configure that in the .htaccess file?
You can use a .htaccess with a simply rule to redirect users to index.html except you :
RewriteEngine on
RewriteCond %{REQUEST_URI} !/index.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /index.html [R=302,L]
Replace 123.123.123.123 by your public ip adress.
You should use your .htaccess to set the default document order:
Tired of having yoursite.com/index.html come up when you go to yoursite.com? Want to change it to be yoursite.com/ILikePizzaSteve.html that comes up instead? No problem!
http://www.javascriptkit.com/howto/htaccess6.shtml
In your case, you won't need to rename the index.php at all - this will do the trick:
DirectoryIndex index.html index.php
Anyone who requests yoursite.com will see the content from index.html. To see the new Wordpress content, just navigate to yoursite.com/index.php

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.

.htaccess - Rewrite a request to one directory before the request is handled by that directory?

I'm trying to exclude all BUT one directory from a rewrite rule. I want the request to be handled by the index.php file in the root directory which will then include the subdirectory's index.php file as part of a script after wrapping it with it's own code.
This is a really strange problem, since I'm trying to wrap Drupal within a Wordpress installation so that the existing site structure can stay put, and I can use a custom template to wrap the drupal output in a slightly customized wordpress theme.
If anybody has any idea how I can do this, I would be very very thankful.
htaccess files seem like arcane arts. Nobody seems to really get them that well, and I am no exception.
RewriteEngine on
RewriteCond $1 !^(drupal_directory|robots\.txt) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
The ! will exclude drupal_directory and robots.txt etc...

Resources