How to make an external Wordpress Main Page? - php

Actually I am running a Wordpress website with a simple template.
Now for SEO and Speed optimization purposes I would like to make a custom HTML page super simple and well optimized but that is not part of the Wordpress structure.
Basically, my own HTML page.
How can I have my Wordpress thinking the main page is that HTML created page as Main page and the rest of the website managed by the Wordpress ?

My answer requires an Apache or Litespeed server (and possibly others) with mod rewrite enabled, and where AllowOverride has not limited your use of .htaccess file.
See: https://codex.wordpress.org/htaccess#General_Examples
According to the WordPress documentation on that page, if you are using an .htaccess file to handle "pretty permalinks", then it creates and uses the following basic .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
What this code does is redirect all requests that are not for an actual file or directory to the index.php file. You can modify this easily and achieve what you want. Simply changing it to something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp_index.php [L]
</IfModule>
# END WordPress
That change would redirect all requests to wp_index.php instead of index.php. So you would make that change, and then rename your index.php file to wp_index.php.
Once that is done, you can create a new index.php file and its contents can be plain HTML. Don't worry about the .php file extension. When somebody goes to your website, if they go to your homepage, the server will serve up the index.php file. For all other requests the server will use wp_index.php and WordPress will handle the request.
Please keep in mind that there are some differences in how .htaccess files work, depending on your server. If my changes don't immediately work, tweaking the .htaccess file contents may be necessary.

Related

I accidentally deleted my .htaccess file how to get it back?

I started using wordpress with my website (through 000webhost) and then I realized that's not really what I want. Not at all. So I went through and deleted all the files. There was a .htaccess file (for Wordpress) and one called .htaccess_origional. I accidentally deleted the original one and now I'm stuck with a Wordpress one that won't work. It was a file with no restrictions or modifications. I remember that it only had one line. Does anybody know how to get it back? Thanks in advance!
You just have to visit Settings > Permalink and save. It will re-generate the .htaccess file.
If you want to create the initial .htaccess file configuration. Here is the initial .htaccess configuraiton
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Reference: https://www.hostinger.com/tutorials/create-default-wordpress-htaccess-file
It's been a while since I last used their service but if I recall correctly you can rebuild your webdir (or whatever it's called).
You'll have to search for this function in your control panel.
When you click this it will reset your server so BE SURE TO HAVE A BACKUP.

PHP Pretty link url using .htaccess

i develop an application using php mysql. below is example of my link.
http://www.domain.com/index.php?page=product&product_id=123&type=virtual
http://www.domain.com/index.php?page=checkout&product_id=456&type=download
i would like to change it to :
http://www.domain.com/product/123/virtual/
http://www.domain.com/checkout/456/download/
I know it can change using rewrite mode on .htaccess, but did i need to rewrite to htaaccess when i create a new page?
wordpress have 7 line (i think) on their .htaccess file.
Can i get a global coding on .htaccess to achive my goal?? im very lazy to create a new rewrite rule everytime i create a new page. i just need to follow this rule
http://www.domain.com/page/parameter/parameter/...
You need to redirect all requests for non existing files to index.php file
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# if file or directory exests, use it
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# else send request to index.php
RewriteRule . index.php
Then, in index.php you parse URI and show the necessary page.

New site is loading Under Construction page instead of Wordpress Site

I created my first online site. I put all my files on the server (I used Wordpress for now) and it's great, but, when I enter my site address (let's say: www.mysite.com) I see only "Under construction". I only see my website after typing: www.mysite.com/index.php.
How can I make www.mysite.com load index.php without needing to enter it in the address bar?
There is probably an index.html file at the root of your public html folder that you need to delete. Once you delete this, your site will load as normal.
Most web servers load .html files before any other files. So if you have index.html and index.php in the root of your public html folder, it will most likely load index.html first.
You also may need to make sure you have an .htaccess file in the root of your public html folder, and that it contains the basic Wordpress code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
More info on that here.

.htaccess redirect from Wordpress URL to Normal site URL

I have rebuild a site. The old site was WordPress and new site is normal php site with same amount of pages.
I do not want to lose the outside plus google links to this pages and need to do a redirect in .htaccess
I know how to do this with normal links e.g. www.domain1.com/guesthouse.html to www.domain2.com/guesthouse.php
I do not understand the wordpress link with no ".php or .html" at the end of the link.
The old link is www.doamin.com/guesthouse/ (only this without .html or .php)
New link must be www.domain.com/gusethouse.php
The WordPress .htaccess file looks like this
`# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress`
Can I delete the above code and replace with
`Redirect 301 /guesthouse/ http://www.domain.com/guesthouse.php`
or must I add it to the existing .htaccess code.
Do not know how to do it right, please help.
Thank you.
The .htaccess file will execute prior to your PHP interpreting engine running. This means that you're higher in the execution chain than the Wordpress software.
If you're not going to use your Wordpress website anymore, then there's no reason to send requests to it!
Instead, just simply remove all of that code, and rewrite the URL's accordingly.

PHP file in WordPress Directory

I have created a folder within WordPress public_html folder and created a test.php file in it as below.
www.mysite.com/myfolder/test.php
When I navigate to this url, I get page not found 404 error. All other files in myfolder, e.g. test.txt load without any issues. It's just php files that are not running. Could anyone please help?
My .htaccess file is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
WordPress has its own .htaccess that is probably treating your URI as some sort of "Search Engine Friendly" thing, and translating it into some other format that WP is expecting. For example, http://www.mysite.com/myfolder/test.php might get rewritten to something like http://www.mysite.com/myfolder/index.php?target=test%25php. That would give a 404 error from within WP (not a real server 404 error). Perhaps something can be done from within WP's configuration, or you could modify the .htaccess to tell it specifically not to rewrite test.php.
This is weird since WP leaves your files alone due to RewriteCond %{REQUEST_FILENAME} !-f condition.
Try creating a myfolder/.htaccess file with this line:
# just one line here
RewriteEngine On
This will basically nullify all rewrite rules of parent folder.
Please check file-folder permission of myfolder. It should not be 777 instead it should be 755 on your server.
Please refer Wordpress php file execution

Categories