WordPress Default .htaccess file

Understanding the WordPress Default .htaccess Rules in full

The code inserted in a file in WordPress root directory folder and wondered what its purpose is. In short, it allows permalinks to work. If that’s not an adequate explanation, and you’d like to really understand what every character means and what its purpose is, this article is for you. We’re going to put this code under a big magnifying glass. In the end, you’ll understand everything there is to know about this block of code.

During installation, WordPress enters the following rules into the .htaccess file in its installation root. This is assuming you are using Apache server software. This is the most commonly used server software. Other software uses different methods to achieve permalink functionality. These other methods are outside the scope of this article. These .htaccess rules are not inserted, however, if you chose the “default” (none) permalink structure. Some themes or plugins may cause additional lines to be entered. These are the rules inserted upon a fresh installation. If there is not a .htaccess file in the installation folder, one is created:

# 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

Many of the above code lines are links to a detailed explanation of the respective line. (Rollover to identify links) The section headings that each link leads to is a link to the official reference at apache.org. If your WordPress installation is not in your site’s public html root, the RewriteBase and final RewriteRule will include the path to your WordPress installation folder.

The main purpose of this rule set is to allow arbitrary paths (permalinks) be sent to the proper WordPress script without causing file/path not found 404 errors. If your permalinks work but you see no .htaccess file on your server, it is because it is hidden. The Linux operating system treats any filename beginning with a dot (.) as a hidden file. Your FTP client has a setting somewhere to enable viewing of hidden files. Select that setting and .htaccess will be visible.

The first and last lines starting with # are comments so you know how these rules ended up in your .htaccess file. WordPress core code uses these comments to locate the related code when it needs to alter the rules for various reasons. They do nothing on their own and serve no other purpose. Any line where the first character is a # is a comment.

The <IfModule mod_rewrite.c> and </IfModule> lines work as a pair and prevent errors if your server does not have the mod_rewrite.c module installed. If the module is missing, the lines in between are ignored. Even if you’re sure your server will always have this module available, you may wish to leave these lines in place so if the module becomes unavailable for any reason, your site will not break.

 RewriteEngine On
This line tells the server to process all following lines beginning with Rewrite* up to the next RewriteEngine line as one logical group. You could set the engine to Off to not process any rules. During testing, this is much easier than commenting out every rule.
 RewriteBase /
This line defines the base from which all relative references are taken. A lone / means the base is your site’s public html root. The actual value will be the path to the installation folder for WordPress. If your blog index page is accessed by http://example.com/myblog/index.php, the line would read RewriteBase /myblog/.
 RewriteRule ^index\.php$ - [L]

This rule prevents any reference to index.php from being processed farther down as a permalink, because it’s not one. This will make more sense in a while. As this is the first rewrite rule, with no conditions above it, this rule is always processed. The rule basically says if the text index.php matches the request portion after the base definition, pass the request along unchanged and do not process any more rules. Let’s take a closer look.

All RewriteRule directives have two arguments and an optional flag setting. The first argument is a regexp (regular expression) to attempt to match against the request. The second argument is what to rewrite if there is a match of the first argument. In our case, is a “Last” flag telling the rewrite engine to not process any more rules if there’s a match to the first argument. The second argument in our case is -, which is a special character telling the engine to not actually rewrite anything, to only do what the flags indicate if there’s a match.

The first argument ^index\.php$, is a regexp, where several characters have special meaning. In this case, they are ^\.$ All other characters are to be literal matches to the request above the base definition. So the regexp index alone means the request must have the corresponding text index somewhere in its content. The ^ character means the match must start at the beginning of the request. Since our base is / (root), ^index means either match a file or folder in root that begins with index. So indexfolder/file.php would match this example regexp fragment. So would indexfile.php. However, sindex.php would not match, since the i is not the first character. In order to match, index has to be the first 5 characters.

In a regexp, the dot . means match any character exactly once. Since we want to only match an actual dot, not any character, we indicate so with a \ backslash preceding the dot. So the regexp ^index. (with a dot but without the \) will match any character after the x, such as indexQmore.php, but ^index\. will only match something with an actual dot after the x, like index.more.php. So now, ^index\.php means the request must start with index.php, such as index.php.moretext. However, the $ means match the very end of the request. So now we have the full ^index\.php$ where the only possible match is index.php. Nothing else will match, index.php.moretext will not match. pre.index.php will not match.
up to full script

 RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond means a condition must be true in order for the next RewriteRule to be processed. %{REQUEST_FILENAME} is a variable set by the server to contain the request URL, not just a filename as it may appear. The -f flag without the ! means the condition is true if the first argument resolves to a valid file. The ! negates the flag, so now with the full !-f the condition is true if the first argument does NOT resolve to a valid file. Since permalinks should not point to any valid system filename, a typical permalink will cause this condition to be true. A reference to a valid server file will cause this condition to be false.
 RewriteCond %{REQUEST_FILENAME} !-d
This is similar to the first condition, except now we’re checking for valid directories (the -d flag) instead of files. Both conditions must be true for the next rewrite rule to be processed. The following rule will only be processed if the request is not a valid file and it is not a valid folder either. If the request is either a valid folder and/or it’s a valid file, the following rule is not processed and the request is passed on unchanged, meaning the file is served normally as though there was no rewrite rule in place.
 RewriteRule . /index.php [L]

This rule is essentially only processed if the request is some sort of permalink. Any other valid file system path is passed on without change. Once again, there are two arguments and a flag. The flag once again means do not process any other rules after this one. There are often no other rules after this, but it is placed here just to be safe. The dot . means match any one character. The /index.php means replace the entire original request with /index.php. If your WordPress installation is above your public html root, you will see the actual folder path here as well. This rule basically says send any permalink requests to index.php for further processing by WordPress. WordPress gets the original request from a different variable, so it doesn’t matter if it gets rewritten here, WordPress will still know what the original request was.

Though the request is sent to the new location (index.php), the user’s browser continues to display the original request in its address bar. This is by design for internal references. External references (URLs that include the http://www.domain.com portion) result in a 302 server response (temporary redirect) and the address bar changes.

The / preceding index.php means this is not a relative link, so the initial RewriteBase / directive does not affect the resulting path. If we omitted the / and just had index.php, we would have a relative link, so the base would be applied before it. Since the base is /, we end up with the same file path either way in this particular case.

Why do we match just one character with the dot (.) argument? Shouldn’t we match the entire request by using .*? We could. But there’s no point. Since the match is not in parenthesis, and there is no $1 style back reference in the /index.php parameter back to any such parenthesis, this means no forward reference is used and the entire request is discarded, to be replaced in its entirety with the next argument, /index.php. It’s a bit more efficient to match any one character than all of them. Since we are required to provide some kind of regexp, a simple dot is the most expedient.

If the original request is always discarded, and previous RewriteCond lines determine if the rewrite is performed, what is the point of requiring a regexp then? In this case, it serves no purpose, thus the dot . is the most expedient regexp we can provide. But in many other situations, the regexp is used to match particular portions of the request. Those portions can then be back referenced in the rewrite parameter to feed useful information from the original request to the new rewritten page. The RewriteRule functionality is much more powerful than what we need here, but it’s getting off topic to discuss in any more detail. That’s for another day.

Now that we see how all permalink requests get sent to index.php, the reason for earlier line RewriteRule ^index\.php$ - can be more clearly seen. Rewritten requests are also evaluated by .htaccess rules just as a fresh request would be. The first RewriteRule line keeps the rewritten request (or a basic initial index.php request) from being re-evaluated for possible permalink handling, as it can’t possibly be a permalink. Besides preventing an endless loop, it’s just more efficient.

If not for these rules, all permalinks would throw a 404 error before WordPress ever got a chance to process the links. What was once mysterious gibberish should at least make some sense by now. As with any computer script, once you understand what the various code bits mean and what is done with the information, it’s not all that complicated. read more on wordpress websites

Pinguis Irish WordPress Courses

WordPress Training Courses Online

WordPress Training based Ireland. We offer free business Website by Pinguis Website Design. We provide a comprehensive list of WordPress Tips and server management hints to experienced users and new wordpress users.

We deal with Changing Server Permissions, installing wordpress for the first time and code snippets. How to find the right web host, How to install WordPress, Getting to know the WordPress Dashboard, Creating Content: Posts vs. Pages and when to use each, How to write a WordPress post, Using WordPress themes, How to use WordPress widgets, Using WordPress plugins, How to create custom WordPress menus
Getting Started the Install, and Planning Your Website. The best WordPress Training.

What is WordPress?

WordPress started off as a blogging platform which allowed users to share with the world their passions, hobbies and images. Businesses quickly noticed how easy and straight forward this system was to use and quickly adopted it as their platform of choice on which to build their business website. In the spirit of WordPress we provide free WordPress Training

Why use WordPress?

Why WordPress is a winning solution for your business website:

1) Extremely easy of use – If you can work Microsoft Word or send an email then WordPress will be a breeze to learn.

2) Millions of businesses around the world now use WordPress. With a massive community online assistance is always online with D.I.Y. enthusiasts waiting to help you. Is it the #1 choice of Content Management Systems available today.

3) Safe and secure  WordPress is updated regularly which makes it harder and harder for hackers and bad guys to break into your website.

4) It’s free  and governed by GPL a body, responsible for free open source software – free to download and use with no monthly or yearly costs.

5) It’s highly customisable – With thousands of free templates or Premium WordPress Themes, the choice is yours. With 100’s of thousands of themes to choose from there is the perfect layout and look for you – available free or to buy today.

Creating a MySQL database for WordPress

Creating a MySQL database with cPanel, which is included in all of hosting plans(may differ with different hosting providers), can be easily accomplished.

Create a MySQL database on your hosting account, you need to log in control Panel. This can be done by either using the Go to cPanel button in the Customer Area My Accounts section or by entering one of the following URLs in your web browser:

http://yourdomainname.com/cpanel

 

Creating MySQL Database with cpanel

In order to connect a new database you need to enter the desired name of the database in the New Database field and click on the Submit button as shown below:

enter your details to create wordpress database

Hint enter keyword into Table Prefix e.g. wp_horseriding to avoid spam emails. Spammers search the internet for newly installed wp_ databases. And make note of Username and password.

WordPress Login Screen

A confirmation screen will be displayed, informing that the database has been successfully created.

Next Run the install

WordPress Login Screen

Planning Your Website

The difference between a disappointing website and a website that becomes the life line of your business? Simple and it all in the planning.

Now lets start we are going to spend some time thinking about our goals and developing the plan.

This phase includes everything from planning our content to creating a budget

Learnables:
  • Defining Your Business Website
  • Content Planning what will be on it
  • Diagram Your Website
  • Have site Budget

What is the purpose of your website.

With WordPress you dont need techanical skills or know-how to use it.

But while WordPress is simple and taken the work out of making a site, the one thing that you still have to do, planning behind your site.

For your site to be an effective business tool, it must reflect the core goals and missions of your company. Whereas many of us start the planning of a site by looking at the available WordPress themes and letting those designs sway our decisions, we really need to be starting from a more strategic point of view and making decisions about themes, plugins etc, based on the bigger picture.

1) What are the values and overall mission of your company?

fundamentally your website must be a reflection of the driving force behind your business. What are you trying to convey? What is it about your business that keeps you motivated to run it every day?

What are the business goals of the company?

Website development to marketing strategy. Get clear on what the specific goals of your company are. Your goals may change over time, so it’s good to review them periodically and make sure your site is still in alignment with your business goals.

Who are your desired clients?

Provide a certain service or make a certain product and do that well. So focus on catering to the customers you really want to attract to ensure you are building a business and client base that will serve its purpose.

What do you want visitors to do at your site – your call to action?

 

Have a Clear, defined serving you and your purpose. The more clear your sense of direction, the better result you will get out of your site.

How to Install WordPress

Your web host may offers a ‘one-click install‘ or similar for WordPress, you may want to choose that.

WordPress while easy to use. Installing it is not for the faint hearted.

2nd:) If Your web host offers a ‘one-click install‘ you may choose that:

  1. Download and unzip the WordPress package if you haven’t already.
  2. Create a database for WordPress on your web server, as well as a MySQL user who has all privileges for accessing and modifying it.
  3. Upload the WordPress files to the desired location on your web server: If you want to install WordPress into the root of your domain (e.g. http://example.com/), move or upload all contents of the unzipped WordPress directory (excluding the WordPress directory itself) into the root directory of your web server.
  4. If you want to have your WordPress installation in its own subdirectory on your web site (e.g. http://example.com/blog/), create the blog directory on your server and upload the contents of the unzipped WordPress package to the directory via FTP.
    Note: If your FTP client has an option to convert file names to lower case, make sure it’s disabled.
  5. Run the WordPress installation script by accessing the URL in a web browser. This should be the URL where you uploaded the WordPress files directly to.
  6. If you installed WordPress in the root directory, you should visit: http://example.com/
  7. If you installed WordPress in its own subdirectory called blog, for example, you should visit: http://example.com/blog/

That’s it! WordPress should now be installed.

Any problems give me a call

I also provide a wordpress install service to get you started.

Hello world!

Welcome to free Business Website by Pinguis Website Design.  Hello world signify the start of something great.  Usually the first output in computer language. It is standard computer speak.

Publish button changed to Submit For Review

How to Fix wordpress Publish button in  from Submit For Review

One of the latest problems i have the (pain) pleasure to come across to during a local business wordpress themes design. It really started off as a bit of a nightmare, when i of realised I could no longer add new pages to my WordPress site or even save the customiser settings for our theme either, faced this problem when working on a custom wordpress roofing theme but found the answer after 6ish hours.

The problem was, there was no “Publish” button. The ‘Publish’ button had be replaced by a “Submit For Review” button. Plus when saving the custom preview seemed to work, but after reloading the page were back to the old settings.

I hope my wordpress tips will help you fix your WordPress website fast and get your website working for you, and not you working for your website.

  1. Changing themes can cause this problem. I recommend you switch back to a default theme (i.e. twenty eleven, twenty twelve etc.) and test if the problem still occurs.
  2. Plugins can also cause this problem. To verify if this is the problem, I recommend deactivating or moving your plugins to a directory outside of the folder and see if the problem still happens.

Login to your phpMyAdmin, repairing the database tables. This can solve the problem.
The WordPress “Publish” button is a “Submit For Review” button problem can also be caused my not having a ‘Primary Key’ and ‘Auto Increment’ in the wp-post table in your database
You can hire me to do this for you. Basically login to your phpMyAdmin and go to the table wp-post. You will see the following error, suggesting that there is no ‘Primary Key’ nor ‘Auto Increment’.

Go to ‘Structure’ and on the ‘ID’ row, click on ‘Primary Key’ to make this this primary row. Once the ‘ID’ row is the ‘Primary Key’ you can then edit the ‘ID’ row and set it to Auto Increment.

 

Pinguis Web dealing with WordPress Errors and custom WordPress Website Designers

� Character Error in WordPress

Different (special) characters showing on all pages and posts even navigation. Lately i have noticed some character showing in my WordPress website design blog. These characters are appearing when the ” , ‘ and space character is used

I have installed some plugins in the hope of speeding up the website. But to my dismay it has not worked and left all these little guys(basically everywhere).

After reading up on solutions i realised that the plugin has changed my wp-config page see below for a sample
In my wp-config there was characters at the start of every line an upside down question mark ¿
This was then translated to � on the front end or my live website.

 
¿// ** MySQL settings - You can get this info from your web host ** //

¿/** The name of the database for WordPress */
¿define('DB_NAME', 'database_name_here');

¿/** MySQL database username */
¿define('DB_USER', 'username_here');

¿/** MySQL database password */
¿define('DB_PASSWORD', 'password_here');

Upon reading further i realised it was a character miscoding error.
How to fix character miscoding errors.

Fixing the Character Encoding Mismatch Problem in WordPress

Step 1) Open the ‘wp-config.php’ file in a text editor such as textwrangler or BBEdit even notepad (the wp-config.php file can be found on the directory where you installed WordPress).

Where to locate the wp-config file with wordpress

Step 2) Find the following two lines and comment them out:

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

They should look like the following after you comment them out:

//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', '');

Step 3) Now upload the updated ‘wp-config.php’ file to your web server.

Write, Edit and Publish Content WordPress

Working with WordPress pages or posts.

How to Write, Add a New Posts and use posts Features

Writing a post or adding content in a WordPress Website can be as easy or as hard as you make it. Their is way around the large learning curve it involves, having said that you have to be prepared to learn and learn from mistakes, many website owners are sick of relying on website designers to upload their content, make small grammatical alterations, spellings corrections and of course dated content with maybe years old, with speed regulations change, that’s not good enough to base your business on.

This would usually involve a phone call or email to the designer, a wait and they they might or might not agree to the changes proposed changes, after this the website owner usually puts up with the changes. Trying to avoiding conflict with the webmaster.

 

Then, they hear about this great software that allows them to login to the back-end and make the changes straight away, and they feel they are able and get their static old Website converted to WordPress.

The beginner finds the interface a bit overwhelming. We will show users the necessary features in order to add new posts so that you can use the features available. It truly is a complex as you want it to be.

 

Our WordPress Posts and Pages layout starts with the Content Editor and a Title and content area.

Title and Content Editor are the most noticeable areas on the Add New Post Editor.

Yours might look slightly different depending on whether you are using the visual or the text editor.

You can switch between visual and text editor while writing a post, but we do not recommend switching as this could mess up your post’s format.

Visual Editor is the beginners text editor with buttons and a visual layout for content area. On the other hand, text editor is a plain text editor where you can actually see the HTML or write your own code.

The first text area on the top is where you add the post’s title. If you are using SEO Friendly URL structure, then WordPress will auto generate post URL based on the title. You can edit the URL by clicking on the edit button. The Post URL or Slug marked above.

The content area is where you will write your post. Use the formatting buttons from the toolbar or use one of the many keyboard shortcuts available which will speed up your writing process. We have use the B for Bold formatting option above.

In the bottom left area of the content editor, WordPress will show you the word count for your post.

One of the beauties of WordPress is as you write the post, it automatically save a draft of the post. This auto-save is stored in your WordPress database temporarily and the date and time is on the bottom right of the screenshot above.

As soon as you save your draft or write more content, WordPress cleans up your autosaved draft and replaces it with the newer up to date one. This process ensures that you do not lose your content due to internet connection or any other failures.

The post editor shows your current draft and autosave status in the bottom next to word count.

Adding Images and Media

Between the title and content fields, there is a large Add Media button. Click on it when you want to upload an image or any other media to your WordPress post. This will launch the media uploader window.

Clicking on the select file button to upload images or any other media to your WordPress site. You can also create galleries and video and audio playlists from uploaded files.

Tip: You can Drag and Drop media files.  Select more than 1 image to create galleries within your post. 

WordPress also comes with some basic image editing tools. You can to edit, flip vertically horizontally, rotate, and crop images in WordPress.

When Publishing a Post Your Options

WordPress post editor is divided into two columns. The column on your left contains the post title and content editor. On your right hand side, you have different meta boxes to configure post options.

The top most meta box in this column is labeled Publish. This is where all the publishing options for your posts are managed.

Save Draft button stores a draft of the post or page that you are working on. WordPress also auto-saves your posts as you write them, its better to save as draft for peace of mind.

Preview button shows a live preview of your post. You can use it to see how your post will look after publishing.

Status allows you to set a status for your post. WordPress automatically handles post status for drafts and published posts. Unless you are using a plugin to add custom statuses, you don’t need to worry about this option.

Click on the Edit link next to visibility to expand it. The first option under visibility will allow you to make your post sticky on front-page. Sticky posts in WordPress are like featured content that are displayed on top of all other posts.

The third option under visibility is labeled private. This allows you to privately publish a post on your WordPress site. The private posts will be visible to users who have the editing privileges on your site.

Click on the edit link next to Publish, and WordPress will display the time and date options. You can use this option to schedule posts or create back dated post in WordPress.

Move to trash allows you to delete a WordPress post. Deleted posts live under trash, and you can restore them if you need to for up to 30 days.

Finally, the publish button makes your WordPress post public, if your site is live your content is now too.

Adding Categories and Tags

You can sort your posts into categories and tags. The categories and tags meta boxes usually appear in the right hand column, below the publish button. Or click posts on the left hand side to reveal the posts drop down which includes categories and tags.

 

Categories and tags help you organize your content in a meaningful and browsable format. Not only your users can easily find your content, it also boosts your site’s SEO. See our guide on the difference between categories and tags and how to use them to sort your content.

Featured Image (Post Thumbnails)

WordPress themes support featured images or post thumbnails for it’s articles. Usually it is one of the last boxes on the right hand column on the post edit screen.

Click on this to set featured image link, and it will bring up the media Library or you can upload your media. You can select an image from a your previous uploads or upload a new image from your computer.

Pinguis Website Design are Experts in converting old dated, static websites to WordPress.

 

Below Options are for the more comfortable User

Screen Options dropdown next to help on the Top Right.

Some of the options on the post edit screen are hidden by default in order to keep wordpress cleaner and simpler for editing. These options are not commonly used by beginners. However, you may need them later, after editing your post.

Click on the Screen Options button on the top right corner of the page. This will show a menu with check boxes next to option names.

Some of the options will already be checked. You can display them by clicking on the checkbox next to an option name, and it will appear on your post edit page. Tip: check a box and find out down the page what it does.

Excerpts

Checking this box adds a meta box below your content editor. You can use this box to add a short summary or excerpt for your post.

WordPress post editing screen Excerpt box

Ideally, you should display summary or excerpt for your posts on your site’s front-page and archives. Full content should only be displayed on the post’s single page.

Send Trackbacks

Send Trackbacks option allows you to notify other blog owners that you have linked to their content.

If another blog owner is running WordPress, then you don’t need to send them trackbacks. Your WordPress site will automatically send them a ping when you publish the post. Which notifys the administration of the post.

Custom Fields

This option will display a user interface for custom fields below your post editor. You can use it to manually enter custom information in your posts.

Discussion

While comments are a great way to engage your audience, sometimes you may not want to have comments on a specific post or a page.

The discussion option displays a meta box below post editor to turn on/off comments and pingbacks for your post.

Since pages are static, most users want to turn off comments on them. You can do so by editing each page.

Once your WordPress site gets some reputation, you will start getting an increase of comment and email spam.

Turn off comments – unless you like spammers telling you what valuable content you have and how they would like to become a guest author on your website.

or email spam where they cant be bothered writing, so they post this

Hello,
How are you? Hope you are fine. I have been checking your website quite often ……

I generally turn all comments off across my blog with a plugin called disable comments

Slug

A slug is a clean title that can be used in URLs.

http://pinguisweb.com/how-to-write-post-edit-and-publish-content-wordpress/

WordPress automatically generates a post slug and displays it as the post URL directly below the post title. You can edit this slug by clicking on the edit link below the post title.

You can also enable the slug option from the Screen Options and edit your post slug at the bottom of the window by scrolling to the very bottom.

Options on the Yoast WordPress SEO Plugin

We have explained the default WordPress post edit settings. Many WordPress plugins will also add their own settings panels on the post edit screen.

Yoast WordPress SEO plugin adds its own settings panel. With a snippet of Search results preosented for you to edit. These are search engine snippets and the main reason people will view your pages after searching and clicking the results with yahoo, google or bing.

SEO Plugin WordPress

 
 
WordPress is a great Content Managment System, second to none with ease of use and flexibility. You have to play with it, learn from mistakes and not to be afraid to make more.

Pinguis Web converting dated, old static websites to WordPress.

htaccess index.html added by Plugin wordpress

This works for any wordpress directory.

If you have a WordPress website and have noticed that some thing has added index.html or a plugin has added it.

Example would be http://pinguisweb.com/about/index.html.

The code below will redirect to http://pinguisweb.com/about/ and drop index.html

try adding

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - 
RewriteRule ^index\.html$ / 
RewriteRule ^(.*)/index\.html$ /$1/ 

to your .htaccess file

How to redirect subdirectory to url with htaccess file

 

This will redirect all references to Car-Sales directory to 
the car-sales file. 

RedirectMatch 301 ^/Car-Sales/.*$ http://pinguisweb.com/car-sales/