I just copied a site over to a new developmental subdomain for some changes. The copy went fine. I used rsync and all files are in place. I dumped the db contents and loaded them up.
Additionally I modified the wp-config.php so that it would have:
define('WP_HOME','http://www.dev.newdomain.tld');
define('WP_SITEURL','http://www.dev.newdomain.tld');
// Just trying to catch any error info:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
#ini_set('display_errors',0);
define('SCRIPT_DEBUG', true);
Posts, plugins, users, etc. all show up just fine on the wp admin interface, however NO content is being displayed on the front end.
If I modify an article from the wp admin, it edits just fine, however when I attempt to view a post I get the following in my browser:
Not Found
The requested URL /path-to-article/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
And the following in my apache error.log:
[Tue Feb 05 05:50:07 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/dev.domain.tld/path-to-post
[Tue Feb 05 05:50:07 2013] [error] [client xxx.xxx.xxx.xxx] File does not exist: /home/username/dev.domain.tld/missing.html
This part leads me to believe that perhaps it is something going on with apache's .htaccess, however it seems to look okay:
# 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
And yes, I have disabled all plugins to see if there could be something going on there. Further, changing the theme to the default "Twenty Twelve" also does not help.
Additionally when looking at the generated page source, there is simply no content within the html.
All I see is a singular access in the access log for the web browser to the root / site resource with NO accompanying other resources (files, images, etc.)
What could be going on here as I am seemingly at an impasse with no errors within the logs whatsoever?
Check your database. Wordpress stores many URLs as absolute URLs, so that's why you might have problems.
Related
I have a VPS running Debian 7, with Virtualmin 4.12gpl and a very vanilla configuration of Apache 2.2.22, PHP 5.4.35 and MySQL 5.5.40 with WordPress 4.01.
I'm experiencing a very odd issue in which certain resources (images and stylesheets, for example) are generating 403 errors for some users and not for others.
For example, some users get a 403 when trying to load this stylesheet: http://lunchtime.org.uk/wp-content/themes/GLA5/style.css (I don't!)
Some users get a 403 when trying to load this image: http://lunchtime.org.uk/wp-content/themes/GLA5/img/podcast.png (I do!)
I've tried a few things:
Changing the permissions has no effect. I've even set it to 777 and the offending files still won't load. Additionally, I can see and download the files through FTP.
I thought mod_security might be the issue, but is not installed
The .htaccess file looks normal for a WordPress installation.
Disabling caching\permalink-related plugins, and clearing my own cache doesn't do anything
Using virtualmin's 'Fix file ownership and permissions' button does nothing.
I've also tried running (as an example)
chown -R www-data:www-data podcast.png
manually, but it has no effect.
It might be worth mentioning that I've set up the same site on two other VPSes, in the same way, and it worked just fine. I migrated all the content to this server on monday, just by copying all the files by FTP and doing a database export\import in phpMyAdmin.
Here's the .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
I won't post the whole apache error log here, but every single error looks like this:
[Fri Nov 21 00:09:21 2014] [crit] [client 141.101.98.168] (13)Permission denied: /home/lunchtime/public_html/wp-content/themes/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
Thank you.
nvm figured it out
...I kid, I kid!
There was a recent update to apache that changed the syntax of the FilterProvider directive. As it turns out, the version of the HTML5 boilerplate .htaccess file I was using was using the old syntax.
If you're encountering this problem, open up your .htaccess file and do a search for
FilterProvider
According to this Github Comment (whose instructions I followed), you should change any line that looks like this:
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
Into this:
FilterProvider COMPRESS DEFLATE "%{CONTENT_TYPE} = 'text/html'"
I am trying to deploy the latest version of my code to Heroku (which works perfectly locally, the exact same code) and I see Error 500. When I look at heroku logs, I see the following error:
2014-06-15T12:41:20.661382+00:00 app[web.1]: [Sun Jun 15 12:41:20.555906 2014] [core:error] [pid 65:tid 139773788280576] [client 10.164.12.48:57546] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
I set the LogLevel to debug:
heroku config:add LOG_LEVEL=DEBUG
But I still get the same error. I also tried adding RewriteBase / to my .htaccess file in the main folder of CakePHP, as some people suggested:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
And I also tried it in the webroot folder, but still no luck!
People also say this could happen due to insufficient permission of /tmp/ folder, but when I change the permission to read and write Git does not see the change. I even force downgrade PHP when deploying on Heroku!
With all the suggestions, I still find it very weird, because I did not change anything in any configuration files nor did I change any permission on any file. Anyone any idea what could cause this? Please don't refer me to other posts in StackOverflow, as I've already seen all of them.
Update:
A rollback to the old code, gets the website working again, but the funny things is that it does not matter what I add to the code (even a line of code or an echo), it crashes the website! So I just want to say that it has nothing to do with what code I have written.
This is now fixed: https://devcenter.heroku.com/changelog-items/486
The underlying issue was the way requests to .php files were proxied to PHP-FPM using default rewrites, which would occasionally interfere with user-land rewrites.
However, what you should really be doing is set your document root so it's app/webroot/, instead of rewriting to that location first (and then having the .htaccess in there do another round of rewrites).
Create, add, commit and push a Procfile that looks like this:
web: vendor/bin/heroku-php-apache2 app/webroot/
Maybe you meant .+ in your second RewriteRule, so it does not apply to requests for / and cause you to loop.
Every time a substitution occurs in RewriteRule in htaccess, the entire set of rules runs again on the substitution.
I'm trying out mod_rewrite on a local playground using MAMP (I know), the rule I'm using seems to be fine according to answers here on stackoverflow, but I keep getting a 404 page, even tried looking at the apache server log, and it seems to be missing the file extension even though the rewrite rule includes it.
Here is my rule:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^test/([0-9]+)/$ public/test.php?id=$1 [NC,L]
Apache log entry:
[Sat Mar 02 00:24:02 2013] [error] [client 127.0.0.1] File does not exist: /Applications/MAMP/htdocs/site/public/test
I have verified it works by placing the same htaccess file inside the sub directory, instead of the root, oddly enough, that works.
The issue seems to be related to the fact .php is missing (based on the apache log).
This one is a little confusing to me.
I'm running a LAMP server with Zend Framework. I've spent a lot of time going over my error logs to try and clean-up any programming errors/bugs.
Most of my specific site errors are done but I looked into my general Apache error log:
/var/log/apache2/error.log
And I'm seeing a lot, almost constant, errors for "File does not exist" like the following (simplified for brevity):
[date] [error] [client #:#:#:#] File does not exist: /var/www/sites/[website folder]/public/explore
[date] [error] [client #:#:#:#] File does not exist: /var/www/sites/[website folder]/public/where-to-buy
[date] [error] [client #:#:#:#] File does not exist: /var/www/sites/[website folder]/public/products
And so on. These folders do not exist because all requests are suppose to be redirected into the index.php file and handled by Zend Framework. The actual controllers and actions exist, such that anyone going to:
http://www.example.com/explore
or
http://www.example.com/where-to-buy/
will get the correct page via Zend Framework.
But I'm not understanding why all these errors are occuring?
If figure it might have something to do with the .htaccess file that redirects most requests (excluding style sheets, documents, images, etc) to the index.php script. This is what mine looks like:
RewriteEngine On
# make sure all requests go to 'www' sub-domain
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# Zend Framework, redirect requests to index.php
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Is Apache trying to resolve the request via an actual directory first and then passing the request to index.php? Which causes the error request?
I'm also not sure why this is getting dumped into the default error log, instead of the error log or the specific site. In other words, I have error logs for each domain such as "example.com_error.log". That might be another indication to the issue. It might be a sequence thing as "error.log" is tired to a "default" site.
Thanks for any insight!
Fozzy
From Regilero:
the fact this is going to the default log is effectively a good hint
on the problem, check the related access.log. Maybe some requests made
on a DNS name not handled in your virtualhost or by web clients not
using HTTP 1/1 (so with no host header) – regilero Oct 19 '11 at 22:52
I was able to compare the access.log with the error.log to investigate my issues.
It was awhile ago but I believe the issue was due to some script going directly to the server via an IP address and trying to use the directory structure from one of the virtually hosted domains.
I am updating a php app, which currently does not use url rewriting. The aim is to hide file extensions. The general structure of the website is as follows
root/
index.php
login.php
page1.php
page2.php
page3.php
page4.php
page5.php
page6.php
page7.php
page8.php
subfolder/
index.php
validpage.php
images/
css/
The subfolder folder in the above structure is unique in that it is the only subfolder containing php files.All of the other files are in the root folder.
I have been through these questions Mod Rewrite and PHP and Mod-Rewrite or PHP router? and mod_rewrite, php and the .htaccess file
Updated htaccess. thanks to #thomasmalt
RewriteEngine on
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -l
RewriteRule ^.*$ - [NC,L]
# only rewrite if the requested file doesn't exist
RewriteCond %{REQUEST_FILENAME} !-s
# add .php to the url
RewriteRule ^(.*)$ $1.php
Problem now is I get a 500 instead of a 404 error, when I try to access a non existent page like localhost/inex.php. The Apache error log gives me the following errors. (I accessed localhost/index which loaded the contents of index.php , followed by which I loaded localhost/inex which gave me a 500 error.)
[Sat Sep 25 14:44:26 2010] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/index
[Sat Sep 25 14:44:36 2010] [error] [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
Update: found the answer to my question here. The question is resolved.
Apache has an option: Options +MultiViews
If you enable this, you don't need to place the file-extention in the url.
I'm not totally sure what you're trying to achieve, and i suspect, no disrespect intended, that you need to understand both mod_rewrite, and the way the webserver and php parses and executes files. I'm not sure how to answer without shooting over or under your level of understanding, but I'll try.
I can tell you what you're current .htaccess is doing: (pseudocode)
if REQUEST_FILENAME does not exist then
rewrite request to /index.php/<the request>
Since index.php is your php script that is executed and everything put in $1 is ignored.
That's why index.php is executed whatever you do.
What you could try to put in your .htaccess is this:
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ $1.php
That should take the request and try to append .php to the end of it. I haven't tested it unfortunately, but you should give it a try. The result should be something like this:
if request is "/news/article"
translate it to "/news/article.php"
And you should read the mod_rewrite documentation twice a day for a month, and buy the O'Reilly book about Regular Expressions.
And if you have administrator access to the development server you should look into
RewriteLogLevel
RewriteLog
From experience, it's harder than it sounds to retro-fit mod_rewrite into an existing site.
This isn't because mod_rewrite is hard -- actually it's relatively easy to set it up and get your new URLs working. The reason it's hard is because your existing site will have all the old URLs hard-coded into it, so you'll have to go through your code changing them all to point to the new URL format - this can be especially tricky if your code builds up URL strings dynamically. You'll need to do lots of testing to make sure you've picked up every possible variation and that they all still work.
Also worth mentioning that search engines and external sites will have historic links in to your site using the old URLs, so you can't get rid of them completely.
I know that doesn't answer your question, but I believe these are important things to consider before you start the project, because for an existing site it isn't the quick-fix that some people make it out to be.
It send you to root because you have RewriteBase / what defining default base ...
If you want to stay in subfolder just make another .htaccess in subfolder with RewriteBase /subfolder/
or remove it
you can make condition like you want
RewriteRule ^(([0-9]+)-)?page(-([0-9]+))?/?$ index.php?page=$2&id=$4 [L]
this will take you from www.abcd.com/2-page-3 to www.abcd.com/index.php?page=2&id=3
Code in index.php doesn't need to contain anything.