How can I ignore folder name in wordpress? - wordpress

I have a local wordpress website on IP "192.168.0.115".
There is a page in it called "Invoice" ("192.168.0.115/invoice").
I have about 800 PDF (invoice) files.
I would like their URL to be "192.168.0.115/invoice/invoice001.pdf", "...002.pdf" and so on.
What I did:
I made a folder called "invoice" in the htdocs folder next to "wp-admin", "wp-content" and "wp-includes" where I put all 800 PDF files.
It worked out - when I entered the URL "192.168.0.115/invoice/invoice001.pdf" it opened the desired PDF file.
But when I entered the url "192.168.0.115/invoice" I had no longer access to the page "Invoice".
Instead I got all of the files listed as in a folder through the browser.
I couldn't access the page, because of the same folder name and same page name -> "invoice".
My question:
Is there any way I can tell wordpress to ignore the folder called "invoice" and load the page with URL "192.168.0.115/invoice" AND in the same time open files with URL "192.168.0.115/invoice/invoice001.pdf"?

If you are using apache you can add a rewrite rule to your .htaccess file.
You can't have a WordPress page and a folder named that same thing. So the first thing you need to do is change your folder name from invoice to my-invoices. Then you add this rule to your .htaccess file:
RewriteRule ^invoice/(.*).pdf$ my-invoices/$1.pdf
Don't forget to rename your folder, but leave your WordPress page slug.
Then you'll be able to go to each of these URLs:
http://192.168.0.115/invoice/
http://192.168.0.115/invoice/invoice001.pdf
Be sure to place your new rewrite rule above the ones for WordPress.

Related

How to redirect wordpress (installed inner directory) to main root address?

I've installed wordpress into a inner directory. like root/mysite . Why I didn't install it on root because there are so many addon domain installed, and I literally don't want to mess all addon domain folders with wordpress files inside root directory. My root directory is for www.example.com . And my wordpress site I've installed on root/mysite, so the url for that is www.example.com/mysites . Is there anyway to redirect www.example.com/mysites to www.example.com . As I said the only reason for not installing wordpress on my root, because I don't want to mess wordpress files, folders with other addon domain's folders on root.
So my main goal is showing a wordpress site on www.jimfahad.com that is installed on www.example.com/mysites. Is there any way?
Yes, you can leave the WordPress install and folders in mysites, but you have to copy the .htaccessfile and the index.php file to root. This will result in the visual URL of WordPress being in root (example.com), but the uploads, theme URLs, etc, being in example.com/mysites.
See the WordPress Codex > Giving WordPress Its Own Directory « Using a pre-existing subdirectory install on how to copy and edit the files:
1) Go to the General settings panel.
2) In the box for Site address (URL): change the address to the root
directory's URL. Example: http://example.com
3) Click Save Changes. (Do not worry about the error message and do
not try to see your blog at this point! You will probably get a
message about file not found.)
4) Copy (NOT MOVE!) the index.php and .htaccess files from the
WordPress (wordpress in our example) directory into the root directory
of your site—the latter is probably named something like www or
public_html. The .htaccess file is invisible, so you may have to set
your FTP client to show hidden files. If you are not using pretty
permalinks, then you may not have a .htaccess file. If you are running
WordPress on a Windows (IIS) server and are using pretty permalinks,
you'll have a web.config rather than a .htaccess file in your
WordPress directory.
5) Edit your root directory's index.php:
6) Open your root directory's index.php file in a text editor. Change
the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to the following, using your directory name for the WordPress core
files:
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
and save the file.
7) Login to your site (if you aren't still already). The URL should
still be http://example.com/wordpress/wp-admin/
8) If you have set up Permalinks, go to the Permalinks panel and
update your Permalink structure. WordPress will automatically update
your .htaccess file if it has the appropriate file permissions. If
WordPress can't write to your .htaccess file, it will display the new
rewrite rules to you, which you should manually copy into your
.htaccess file (in the same directory as the main index.php file.)

hosting webapplication on wordpress website

i have WordPress installed in the root http://ibdaa.info
what a need to do is to make sub-directory likee: http://ibdaa.info/app and upload my website to this sub-directory its contain (html,css,js)
i make try to just upload my site to previous link but it seem doesn't work
You will have to upload all the files present in the root folder of http://ibdaa.info to http://ibdaa.info/app and then change the site_url and the wordpress_url from the backend to the new url which in case is http://ibdaa.info/app and you will have to change the new url to point to the /app directory in the .htaccess file also.
A similar way would be to define constants in the wp-config.php file with the new url's
define('WP_HOME','http://ibdaa.info/app');
define('WP_SITEURL','http://ibdaa.info/app');

Migrate wordpress site from subfolder to root, remove static page

My website have structure like this:
In root domain I have static html page "portfolio" (which I won't need it anymore, becauose I'll create it in wordpress):
http://www.natasamedvesek.com/
and I have installed wordpress for blog in subdirectory:
"natasamedvesek.com/blog/"
Now I have also all my pages structured like this "/blog/about" , "/blog/info" .... .
Now I'm asking what to do:
(1) move wordpress instalation from subdirectory "blog" to root directory.
or
(1) leave wordpress instalation as it is, in subdirectory "blog" and create redirect 301
My new structure would look like this:
"natasamedvesek.com" ---> portfolio "natasamedvesek.com/about" ---->
page "about" "natasamedvesek.com/info" ----> page "info" . . .
"natasamedvesek.com/blog/" ---> page of postsIt's very important that I won't lost all my existing likes and shares from facebook, from all of my posts? What about my existing rank for SEO on google?
If I do create redirect 301, what I have to do?
Is this correct way, if I would put this code in .htaccess file
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.natasamedvesek.COM/$1 [R=301,L]
Thanks for answers
It's much easier than using redirects; you can use the pre-existing subdirectory install and have admin at /blog/ while root appears to be at root.
From Giving WordPress Its Own Directory « Using a pre-existing subdirectory install
1) Go to the General panel.
2) In the box for Site address (URL): change the address to the root directory's URL http://www.natasamedvesek.com
3) Click Save Changes. (Do not worry about the error message and do not try to see your site at this point).
4) Copy (NOT MOVE!) the index.php and .htaccess files from the blog directory into the root directory of your site.
5) Edit your root directory's index.php. Open your root directory's index.php file in a text editor. Change the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to the following, using your directory name for the WordPress core files:
require( dirname( __FILE__ ) . '/blog/wp-blog-header.php' );
and save the file.
6) Login to your site (if you aren't still already). The admin URL should still be http://www.natasamedvesek.com/blog/wp-admin/
7) If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)
very important that I won't lost all my existing likes and shares from
facebook...
You will lose your Facebook shares because the URL is changing, and there is no way to change an incoming Facebook link. And your SEO will take a temporary hit because you are changing URLs, at least until Google reindexes the site.

Change a php file path in Wordpress

I am working on a wordpress plugin, I have an external php file that I need to use It should be placed in the Wp directory "http://localhost/forever/"
(where my wp files are uploaded).
For some reason I need to put this php file in an other folder but it should act like it's in Wp directory like changing its real path.

Same wordpress directory and parameter conflict

root_directory:
wp-content/
wp-admin/
wp-includes/
stackoverflow
The text above is the sample directories in my root folder.
This time I want to create a page named "stackoverflow".
Everything is working, the page is created and the url is
www.mywebsite.com/stackoverflow
Now, every time I visit www.mywebsite.com/stackoverflow, it only loads the directory and not the page.
Any solutions for this guys? Thanks!
You have to change your directory name or your file name.
You cant keep directory and file with same name in same directory.

Resources