Rectangle 27 2

It's pretty easy to use, and when I'm doing a redesign or changing site structure I use this plugin for a few months (until the search engines have re-indexed the site). Of course, you can leave it on indefinitely if you wish.

Jared, I'm thinking your recommendation might be the easiest way. Thanks!

php - WordPress .htaccess RewriteRule not working - Stack Overflow

php wordpress .htaccess
Rectangle 27 3

The only reason I can think that apache might not be reading the user's IP correctly is if you're behind a proxy or load balancer. If that is the case you would use X-Forwarded-For instead of ip. In PHP, you can confirm if you're behind a proxy by comparing $_SERVER['REMOTE_ADDR'] and $_SERVER['HTTP_X_FORWARDED_FOR'].

If that is not the issue so you might have better luck finding an answer at ServerFault.

I can offer you some workarounds though. The easiest solution may be to use one of several WordPress security plugins that allow you to restrict access to the backend by IP address.

Alternatively, in your theme or in a plugin you can implement this same sort of authentication logic:

add_action('init', function() {
    $allowed_ips = array('50.153.218.4');
    if(is_admin() || $GLOBALS['pagenow'] == 'wp-login.php') {
        if( !DOING_AJAX && !in_array($_SERVER['REMOTE_ADDR'], $allowed_ips) ) {
            wp_die('', 'Forbidden' array(
                'response' => 403
            ));
        }
    }
});

Update: From the comments it looks like there is a proxy involved. This should work:

ErrorDocument 401 default
ErrorDocument 403 default

SetEnvIF X-Forwarded-For "50.153.218.4" AllowIP

# Disallow access for everyone except these IPs
<RequireAny>
    Require env AllowIP
</RequireAny>

# Allow plugin access to admin-ajax.php around password protection
<Files admin-ajax.php>
    <RequireAll>
        Require all granted
    </RequireAll>
</Files>

and

# Protect WordPress
ErrorDocument 401 default
ErrorDocument 403 default

SetEnvIF X-Forwarded-For "50.153.218.4" AllowIP

<Files wp-login.php>
    <RequireAny>
         Require env AllowIP
    </RequireAny>
</Files>

You should also be able to use a similar method using the "Allow, Deny" syntax.

I am using Cloudflare for CDN and nginx reverse proxy for speed improvements so one of those must be causing it. Although I had both before I upgraded to new apache and it seemed to work then. I did indeed confirm that REMOTE_ADDR and HTTP_X_FORWARDED_FOR do not match. Would you know off the top of your head which one is the cause? I'd rather do it through apache than PHP since it will probably be safer and faster. I've tried a few WordPress security plugins but they all eventually fail or still add too much load to the server in case of brute force attacks.

@zen It must be the reverse proxy. A reverse proxy sits between the webserver and the user. All of your requests are actually coming from the proxy so the IP address you see is the proxy's. A CDN would not cause this sort of issue. It's strange that before the upgrade this wasn't an issue. It might having something to do with configuring apache to account for the reverse proxy. If you're interested I would ask on ServerFault.

thanks for the edit. I will mark this the correct answer since that is a good solution for now.

wordpress - Apache 2.4 Require ip not working - Stack Overflow

wordpress apache .htaccess
Rectangle 27 1

AllowOverride Not Enabled Your server may not have the AllowOverride directive enabled. If the AllowOverride directive is set to None in your Apache httpd.config file, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem. When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files. Example of enabled AllowOverride directive in httpd.config:

<Directory />
    Options FollowSymLinks
    AllowOverride All
 </Directory>

You may also have to enable the AllowOverride directive in your DocumentRoot:

<Directory /var/www/html>
    # ... other directives...
    AllowOverride All
 </Directory>

You may also have to change the AllowOverride settings for the site. This is surely the case when using Mac OS X Server, but might be likewise with other systems. Usually you can find the site configuration files in /etc/httpd/sites/ 

If you don't want to set AllowOverride to all (as it is above) then your AllowOverride list must include the FileInfo directive. You must restart your Apache server for any httpd.config file changes to take effect. For more information on which overrides are allowed, read about Apache Core Features.

php - Wordpress Permalinks does not work - Stack Overflow

php wordpress apache .htaccess mod-rewrite
Rectangle 27 2

It looks like there is some duplicate request (also judging from the provided access.log). This might be caused by a missing/inaccessible file on the server (which is there/accessible on localhost, thus not causing problems there). If this is requested, some rewrite-code (either within WP or mod_rewrite in .htaccess) rewrites the "failing" request and sends it to the main script. Then, in the main script, the session data gets overwritten with a new captcha...

Perhaps you could also write some debugging messages to either the error.log or some other logging facility. That might also help finding this.

php - Captcha is working fine on localhost , but not online - Stack Ov...

php ajax wordpress captcha
Rectangle 27 1

Anchor elements should not contain paragraph elements. Technically this is allowed in HTML5, but some browsers may not handle it correctly. My guess is you're viewing the source in your browser's dev tools and it is auto-closing the anchor when it encounters the paragraph. If this is the case, viewing the actual source should show the HTML formatted as expected, even though it renders as if the anchor is closing early. Try placing the anchor inside the paragraph or setting the display attribute of the anchor to block. More info:

I tried changing my p tag to a div tag and it is still not working. Also, the same code was working properly when I was using it in index.php or category.php, etc.

php - Permalink not working as expected in wordpress category dropdown...

php ajax wordpress
Rectangle 27 1

I had the similar problem today when my EC2 instance suddenly lost access to RDS instance and Wordpress stopped working. The security groups were correct and I could even connect to MySQL from console on EC2 instance but not from PHP. For some reason restarting EC2 server helped me.

mysql - Can't connect to RDS instance from EC2 instance - Stack Overfl...

mysql amazon-web-services amazon-ec2 amazon-rds
Rectangle 27 0

The issue is not due to WordPress configuration or PHP configuration. The reason of .htaccess not working is: In my Apache virtual host settings, it is configured to ignore .htaccess by:

AllowOverride None

To disable this lock, change the value in the virtual host file ( in sites-enabled folder ) to:

AllowOverride All

wordpress - Custom Permalink of Custom Post Type - Stack Overflow

wordpress .htaccess mod-rewrite
Rectangle 27 0

When you make configuration changes such as AllowOverride in the config, make sure your do a restart on Apache2 so the changes become effective. Give that a shot.

php - WordPress not working with .htaccess - Stack Overflow

php wordpress apache .htaccess mod-rewrite
Rectangle 27 0

SO after digging deeper and looking into this further I found a fix. Not sure it is the BEST solution but its working.

#Manager - A customer content manager
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
#end Manager

# 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
DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|logout.php|install.php)$">
Order allow,deny
allow from all
</FilesMatch>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /manager/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

The top portion isn't required but I added this for file protection/security.

RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]

I then input the information in the sub-directory's .htaccess file for url rewriting. From here I can manipulate the URL converting it into a Array list for further sorting and database calling.

php - Wordpress .htaccess preventing sub folder from rewriting its own...

php wordpress .htaccess mod-rewrite
Rectangle 27 0

I had a similar problem after changing the root directory of my blog (before migration) and trying to coming back... Changing the data in my DB was not working for me.

I still did not figure out why but I had a "page not found" when I tried to access categories, tags,... and even on the home page. Links to articles worked correcly and the administration page was not accessible (wp-admin rewritten twice in the url).

  • After the "define" statements (just before the comment line that says "That's all, stop editing!"), insert a new line, and type: define('RELOCATE',true);
  • Open a web browser and manually point it to wp-login.php on the new server.

I had to change the value of the root directory in the administration page (after these actions gave me back the access to it).

php - .htaccess WP-admin url twice - Stack Overflow

php wordpress apache .htaccess mod-rewrite
Rectangle 27 0

If you use the latest Wordpress version the plugin may not work even if it worked with other versions. As you see from your link it is not the most popular plugin nor it has any evidence to be working in the latest WP version. Consider searching for another plugin that does the same job.

No other option other than this suggestion, some sort of code wil help this overcome my problem? Thanks anyway for the quick reply.

I am afraid you will need to find the error in the code to fix the problem.

php - Wordpress plugin failed to load other plugins.? Help me out - St...

php wordpress wordpress-plugin wordpress-plugin-dev
Rectangle 27 0

file_get_Contents loads the file as a string, PHP is not interpreted. What you want is include or require which will interpret the php.

<div class="main-navigation">
    <?php
        include("some/filesystem/path/nav.php");
    ?>
</div>

Note the change in that you want to use the path to the file on the filesystem, presumably you are loading a file on the same server that is calling the include. If this is the case, you dont need to add the handlers unless you plan on hitting the php file directly via the webserver like http://somedomain.com/somefile.phtml

That has nothing to do with my problem, the problem is that the PHP is getting parsed as a comment and not a PHP script.

So you are actually trying to getcontents on a remote resource?

No, the nav.php file loads the Wordpress menu in HTML format and the boxbilling theme needs to load that file, that's all I need help with but the php is being parsed as a comment and not actual php code.

So wp_nav_menu gets includes or otherwise generates the block with the div.main-navigation?

It just gives you the HTML code for the menu which goes under the .main-navigation to use the CSS defined in .main-navigation

html - PHP Code Not Working in PHTML File - Stack Overflow

php html wordpress .htaccess phtml
Rectangle 27 0

This seems to be your .htaccess file not working with nginx, Have you converted your wordpress .htaccess file to nginx configuration ?

install wordpress in osx with nginx and php failed - Stack Overflow

php wordpress osx nginx
Rectangle 27 0

word press like other web apps uses session for login. and there is a problem in sessions when working with different domains.they are not sent to any other site even any other sub domain let alone another domain.so try a way to send your sessions!!!

Yeah thanks. i figured it was somethign to do with cross domains or something . I have been trying a lot of things , Im gonna keep trying. Thanks

php - log into wordpress using POST data - Stack Overflow

php wordpress curl
Rectangle 27 0

I have had this happen to me once with a newly setup custom theme and the issue was related to a typo/duplicate of sorts when I registered a couple of the menus in the functions file. I created menus and found that the menus were gone without explanation randomly at another time even when not working on the website. As a thought since it might be quick to try, consider exploring the same option and make sure that the menus are registered correctly and also rename them completely.

php - Wordpress Nav Menu page items disappearing randomly - Stack Over...

php wordpress menuitem multisite
Rectangle 27 0

You appear not to have a PostsController.php file in your app/Controller directory. Might that be the case? CakePHP seems to be working up to that point though given the fact that you are getting to app/webroot/index.php.

That's the part that is confusing me. PostsController.php exists under app/Controller/PostsController.php. And CakePHP is reading it - its contents is displayed right at the top of the page. Why is it reading the file and then not executing it, and complaining that it is missing? It is almost as if it doesn't consider it real PHP script, maybe?

Ah, that's where the problem was! Two things: some funky encoding ( probably what will happen when you are copying a tutorial example from the internet ) and also something odd: even though apache is set up to treat .php files as PHP, and does so on other folders, it isn't doing so for files inside the CakePHP folder. Thus I needed to add the <?php ?> tags around the code in PostsController.php. I'll have to get to the bottom of that. Your answer was helpful to steer me in the right direction so I'll accept it. Thanks!

php - CakePHP on MAMP: CakePHP install and WordPress install both in s...

php apache .htaccess cakephp
Rectangle 27 0

please check this plugin it will rewrite the permalink as you want without any coding knowledge.

thanks for the reply. My work is done. yes this plugin can be helpful.

php - WordPress .htaccess not working for rewriterule - Stack Overflow

php wordpress .htaccess
Rectangle 27 0

One possible cause could be case sensitivity. You state that your production server runs linux, which IS case sensitive. If your development server is a mac, you are most likely working with a non-case sensitive filesystem.

Possible solution: safe all images in all-lower-case and user lowercase directories. When calling file_exists, call strtolower on the file name.

If you are developing on a windows machine, you might be using \ as directory separators.

Possible solution: Always use / as directory separators, since that will work on all systems.

Do you have these issues when saving to a folder that is above your document root?

php - file_exists() not working on AWS ec2 server, even though works o...

php wordpress amazon-web-services amazon-ec2 buddypress
Rectangle 27 0

First, I debug to find where the php.ini locates by create a info.php on the working site.

<? php phpinfo(); ?>

Then, I find if there is any value on auto_prepend_file =. If yes, delete it.

Then I open the site1.conf file and add the auto_prepend_file line instead of the one from .htaccess

<Directory "/path/to/folder">
    php_value auto_prepend_file /absolute/path/to/apache-prepend.php
</Directory>

After restarting the Apache server, everything works again!

sudo systemctl restart apache2

wordpress - How do I resolve "PHP Fatal error: Unknown: Failed opening...

php wordpress .htaccess ubuntu-16.04 ubuntu-server
Rectangle 27 0

SO after digging deeper and looking into this further I found a fix. Not sure it is the BEST solution but its working.

#Manager - A customer content manager
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
#end Manager

# 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
DirectoryIndex index.php
<FilesMatch "\.(php|inc)$">
Order allow,deny
deny from all
</FilesMatch>
<FilesMatch "(index.php|logout.php|install.php)$">
Order allow,deny
allow from all
</FilesMatch>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /manager/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>

The top portion isn't required but I added this for file protection/security.

RewriteCond %{REQUEST_URI} ^/manager/(.*)$ [OR]

I then input the information in the sub-directory's .htaccess file for url rewriting. From here I can manipulate the URL converting it into a Array list for further sorting and database calling.

php - Wordpress .htaccess preventing sub folder from rewriting its own...

php wordpress .htaccess mod-rewrite