I have been searching for some configurations of .htaccess, filters and hooks to make able to manage the inner site uri's. The goal was force login, register and admin pages through SSL, and all the other pages through HTTP.

Although it can be easy when you have the same domain for both, http and https, it could be quite difficult when the domain is different, and even the PATH different (for example: HTTP on mydomain.com/blog, and HTTPS on mydomain.sslserver.com).

Neither this question (Use a different domain for SSL) nor the HTTPS PlugIn, helped to reach this goal with success. For this reason I began making my own customization taking advantage of some other information.

The problem is I am very new with WordPress code, and trying to find out how the redirection works, I am stuck without understanding the inner WordPress redirection.

Then, my question: If the RewriteRule does not pass the PATH of the permalink (for example, a path to a post or a category), and only is rewriting to /index.php, how can this file 'knows' which is the queried post or category?

I supposed that in some part of the code it would need use the $_SERVER["REQUEST_URI"] or the $_SERVER['REQUEST_URI'] or the $_SERVER['ORIG_PATH_INFO'] somewhere, since it works without converting the permalink's PATH to a QueryString, and without sending any POST or GET data.

Please, I have been seeking for some tutorial telling what is going on and did not find any thing with a clear and plane explanation. Maybe there are too many pages of close information related and the Searcher do not show me the correct page, maybe I am not searching correctly, but I really need to know how it works.


3 Answers 3


Parsing of the requested URL happens in the file wp-includes/class-wp.php. The magic happens starting at line 148 in the parse_request function. For path info style permalinks, $_SERVER['PATH_INFO'] is used, for pretty permalinks, $_SERVER['REQUEST_URI'] is used.

  • Exactly!! That's what I supposed, but I didn't know where it was treated: $_SERVER['REQUEST_URI'] = '/testting/2014/07/hello-world/'. But $_SERVER['PATH_INFO'] is not defined as a key.
    – rellampec
    Commented Jul 10, 2014 at 12:31
  • The other variable with something interesting in this way is $_SERVER['REDIRECT_URL'] = '/testting/2014/07/hello-world/'
    – rellampec
    Commented Jul 10, 2014 at 12:35
  • PATH_INFO is only populated when using "almost pretty" permalinks, on servers that don't have mod_rewrite. they're in the form index.php/testting/2014/07/hello-world/.
    – Milo
    Commented Jul 10, 2014 at 15:41

I will expand my question with more information for better understanding. At the /testting/ folder (the blog's directory). The basic .htaccess shows:

RewriteBase /testting/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /testting/index.php [L]

Once 'www.domain.tld/testting/2014/07/hello-world/' is called, it rewrites '/testting/2014/07/hello-world/' to '/testting/index.php', but does not pass '2014/07/hello-world/' as a query; as other .htaccess rules would do -> as example:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [L]

For this reason, I do not understand how the 'index.php' can know the PATH '2014/07/hello-world/' (the post in this case). And that is why I supposed WordPress is using $_SERVER['REQUEST_URI'] or the $_SERVER['ORIG_PATH_INFO'] somewhere. Because '2014/07/hello-world/' is not passed through POST or GET (is it?).

Before beginning to learn how hooks and filters are working, I would need to resolve this basic issue. However, as I said at the very beginning, I did not find any documentations telling what is going on with it.

Thank you again!


If i understand right what you're looking for is get_query_var( $var ) which return the given var passed trough the rewrite process.


Here a list of WordPress Query Vars


For debugging purpose you can get a list of all the query_vars using:

global $wp_query;


Insert the following code in wp-content/themes/your-theme/functions.php:

// Trigger an hook just before the current template is loaded
function all_my_vars_152651 () {
    global $wp_query;
  • Thank you for your reply. I have tried it, but is not what I am looking for. Added at the wp-settings.php, just before "if (SHORTINIT) return false;" the var_dump returns Null. The requested uri was 2014/07/hello-world/ .
    – rellampec
    Commented Jul 6, 2014 at 22:36
  • And if I ad the var_dump at the end of the settings.php it shows "array(0) { } "
    – rellampec
    Commented Jul 6, 2014 at 23:08
  • You shouldn't edit any WordPress file apart for plugins or themes (if you try to var_dump $wp_query inside wp-settings.php, for example, nothing comes out because it hasn't been initialized yet). Paste the code inside the file functions.php in the selected theme folder instead. Commented Jul 8, 2014 at 13:58
  • Thank you again MiCc83@ . I was asking for another issue. However it will be useful for other things I need to do later.
    – rellampec
    Commented Jul 10, 2014 at 6:34
  • MiCc83@ Your Update worked, and I could use it with the global $_SERVER to find out all the values.
    – rellampec
    Commented Jul 10, 2014 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.