Wordpress - problem with .htaccess file

Hey peeps,

im trying to change the permalink structure in wordpress but im having problems with .htaccess.

I go into wp settings and channge permalink settings to %postname%. It then tells me to update my .htaccess file -
i dont see one already there so i take a blank .rtf file, insert the code WP gives me. upload it to the root of the wp installation and change its name to .htaccess.

from everything ive read thats all i should need to do.
problem is, when i do this, the site does not work at all. i cant even refresh the page without getting an error.

what am i doing wrong?

Hi there,

That’s a bit bizarre.
When you update your permalink structure, WP should normally create and/or modify the .htaccess file in the root of your WP installation.

If WP can’t update your .htaccess file automatically, it will tell you something like “If your .htaccess file were writable, we could do this automatically, but it isn’t…” near the bottom of the Settings → Permalinks panel.
Do you see this message?

Other than that, there are quite a lot of factors which could be influencing this.
Some hosts (e.g. Godaddy) may not show or allow you to edit .htaccess if you install WordPress through the Godaddy Hosting Connection installation.

What is your hosting environment?
Let us know and I’m sure we can get to the bottom of this.

Oh, and by the way, maybe the .rtf file is causing WP to choke.
Try creating a plain .txt file instead and see if that makes a difference.

Hello, Pullo.

The hosting is with Managed Way.
I installed WP manually.
WP did not create an htaccess file when i installed it - at least not that i could find on the root level of the WP installation.
if your wondering, the ftp client i use is Transmit. I selected “show hidden files” in the view options, and again did not see an htaccess file. from what ive read WP does not always create one.

I am getting the message of “If your .htaccess file were writable, we could do this automatically, but it isn’t…” but as i said there is no htaccess file visible. Is there somewhere it would be other than the root level of WP?

The version of WP is 3.4.1

the rtf is not causing any problems when it is an rtf. its when i rename it to .htacceess that it causes problems.
i have also tried this with a txt. same result. as a txt it does nothing, when renamed to .htaccess it causes the site not to work and i get the following message:
"Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [noparse]webmaster@mysite.com[/noparse] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2 Server at porthuronairportshuttle.com Port 80"

the site is porthuronairportshuttle.com

Ok then, let’s see if this works:
Create a blank txt file on your desktop.
Call it 1.htaccess.
Upload it to the root of your WP install.
Rename it to .htaccess.
Set the permissions on the newly-uploaded file to 666.
Then try changing the permalink structure in your WP back end.
Any difference?
FWIW it sounds to me like you are doing everything correctly.

followed your instructions precisely.

Doesnt matter how i do it. Every time a file called .htaccess is in the root of wordpress, the entire site stops functioning. regardless of permissions or if it was originally a plain text or rich text or whatever.

the minute it is renamed to something else (1.htaccess, htaccess.txt, etc) it is ignored and everything goes back to normal.

Ok, that’s weird.
Does even a blank .htaccess file stops WP from working?

What is your directory structure?
Is WP in the root of your webspace or a subdirectory?

WP is at the root of the domain - however there are multiple domains on the ftp.
so its
ftp root>domains>domain.com>public_html>here are the wordpress files

yes even a blank .htaccess file stops the site from working - not just wordpres, THE ENTIRE DOMAIN - even a static html page will not load with a .htaccess file (blank or not).

there are no other .htaccess files in the domain and as far as i can see none on this ftp whatsoever.

Ok.
Make a .htaccess file as described above and stick this code in it:

Redirect 301 / http://www.sitepoint.com/

Upload it to your FTP root (i.e. the root of everything) and then try to call up your site in a browser.
Does that have any effect?

Also, when doing this try clearing the cache in your browser, or using a different browser from normal.

I have a similar setup for you and this works for me.
It’s starting to sound that this might be an issue with the hosting company.

P.S. If it works, don’t leave this file on your server as it redirects everything to SitePoint.

That worked.

it redirected to sitepoint.
i have removed it from the ftp root.

Ok, at least we know that this functionality is not being blocked by your host.
What happens if you move it into domain.com?

What is your WordPress Address and your Site Address set to in your WP backend?

the redirect works from the domain root (domain.com folder)

and as far as wp address and site address in wp backend - im not clear on what you are talking about here

On the Settings->General screen in a single site installation of WordPress, there are two fields named “WordPress address (URL)” and “Site address (URL)”.They control where WordPress thinks your site is located.

The “WordPress URL” is the address you want people to type in their browser to reach your WordPress blog.
The “Site URL” is the address where your WordPress core files reside.

On my site, for example, my WP URL is http://domain.com, my site URL is http://mysite.com/mywordpressinstall.
This results (for me at least) in WP dropping a .htaccess file in my ‘domain.com’ folder, which directs all incoming traffic to the ‘mywordpressinstall’ folder.

Silly question: what happens if you drop the .htaccess file into the public_html folder. Does WP still choke?

both are pointing to http://porthuronairportshuttle.com which is where the visitors are supposed to go and where the wp files are installed.

as stated earlier public_html IS where the wordpress files are. putting a blank .htaccess file there chokes the site and putting one there with the redirect, well, redirects as it should (as we already saw).

maybe i wasnt clear earlier. the WP files are on the root level of public_html, NOT in a subfolder.

just for fun i tried pointing the redirect to http://porthuronairportshuttle.com - which causes an infinite loop which entertains me slightly.

Glad you’re having fun, as this must actually be quite frustrating :slight_smile:
If it makes you feel any better, I’ve got WP set up locally on a virtual machine (for testing) and I just killed that by messing about with the .htaccess file.

Anyway, sorry I misunderstood your folder structure.
So putting a .htaccess file in your WP root with the redirect to SitePoint works as expected.
At least now we have a .htaccess file in your WP root which is not being ignored.

Can you set the file permissions on the .htaccess file to 777 (the max possible), then try and update your permalink structure via the WP backend.
What does WP say?
Do you still get the “If your .htaccess file were writable …” message?

If not, then can you pull the file back off the server and see what WP has written to it.

it should be noted that i tried the .htaccess file with the parameters wp generates for you if your .htaccess file is not writable - this also choked the system.

also another amusing thing:

when the .htaccess file is a redirect to sitepoint, i try to update the permalink structure (with max permissions) and i discover sitepoint is built with wordpress (i am redirected to sitepoint.com/wp-login.php)

[B][U]so i blanked out the .htaccess file and uploaded it again (with max permissions), updated the permalink structure… and it seems to have worked this time. what we did differently i am unsure of.

i downloaded the file.

here is what WP wrote to the 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

why did this work? what did we/I do differently? im confused…[/U][/B]

Sorry man, I’m out of ideas.
It’s quite a difficult issue to debug remotely.
It sounds like you are doing everything correctly, but if you check WP forums, there are actually quite a lot of people having problems with this kind of thing
E.g. here: http://wordpress.org/support/topic/page-not-found-after-changing-permalink-to-postname (I know that’s not 100% your issue, but you get the idea).

If I was you, I would read this: http://codex.wordpress.org/Using_Permalinks and try what they suggest there.
If that fails, I would contact your hosting company for help.
They will be in a much better position to help you than me.

It would also be nice if you post back here if you manage to solve your issue and tell us how you did it.
Oh, and don’t forget to change the permissions back to something sensible on the .htaccess file.

Sorry I couldn’t help you more.

read my last post

Ok, so you must have edited that while I was replying. :slight_smile:
Does that mean that everything is working and that your permalink structure is now how you wanted it?

Yes. the site is working perfectly and the permalinks are %postname% as they should be.
im still trying to figure out what was done differently than before.

the facts:

• previous attempts with a blank .htaccess file choked the system.
• previous attempts with the exact same code, manually entered (minus “# BEGIN WordPress” and “# END WordPress”) choked the system.

speculation:
• “# END WordPress” is a comment and therefore should not have any effect whatsoever on the file.
• file permissions at anything higher than “444” should not have that type of effect on the file

i just noticed, however that the file is now at 644 permissions - i had not changed it yet so im thinking WP changed it automatically.