homepage Welcome to WebmasterWorld Guest from 54.166.122.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Wordpress Problem with my htaccess file
mkingsle

5+ Year Member



 
Msg#: 4204810 posted 3:22 pm on Sep 21, 2010 (gmt 0)

Hello Everyone:

Seems like nothing works for me the first go around, and Wordpress is my latest hiccup in my quest to learn web design.

I'll try to summarize what I've done thus far:

1.) I installed wordpress in a sub-directory to use as a blog for the site.

2.) At first, I was not able to log in at all ( It would just refresh the page.)

3.) Discovered it was conflicting with my htaccess file somehow. ( I know this because when I removed it from the server I was able to log in just fine. )

4.) Using the process of elimination, I was able to discover the code that is giving the problem:

# Redirect direct client requests to remove .php extensions
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?#\ ]+\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ [http://www.mywebsite.com/$1] [R=301,L]

This is where I get stumped. The rule works just fine for my website, which I've had running for over a year, but does not interact well with wordpress. I don't get why?

JDMorgan was nice enough to help me by providing the above solution, which strips the php extension, which is what I want.

I've researched this on Google, and it seems no one is having this problem, so maybe I need to rewrite the rule somehow or...is it possible that I could put another htaccess file in the subdirectory and somehow turn off the rewrite engine?

Any help is greatly appreciated.

Michael

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4204810 posted 3:55 pm on Sep 21, 2010 (gmt 0)

I would guess that your WordPress configuration is set to link to "/index.php" instead of "/", and the resulting requests are triggering the "remove .php" redirect. This later causes problems inside the WP script(s) that examine the client-requested URL-path, expecting "/index.php" but seeing only "/".

The best solution would be to change the WP configuration to to link to and expect only "/" in requested URLs.

The less-desirable and more problematic solution would be to exclude requests containing the path to the WP subdirectory (if you have one) from all of your rewriterules.

This could also be a problem with rule scope or rule order. Make sure you've ordered your rules properly (see the recent thread in our Apache Forum Library), and be sure that your RewriteRule patterns are as specific as possible without being too selective.

The "remove .php" rule will only be invoked if the client requests a URL ending in .php. So either one or more of your other rules or one of the WP scripts is publishing a link to "<something>.php" or is redirecting to "<something>.php". In either case, this is incorrect: Your site must always link to the 'final' and 'correct' URL, and you cannot rely on a redirect to "fix this." Such a redirect is only good for "fixing" incorrect/obsolete links coming from *other* Web sites by speeding up their replacement in search engine results listings, and by helping to prevent other Webmasters/bloggers/forum-posters from linking to the incorrect URLs with .php on the end.

Jim

mkingsle

5+ Year Member



 
Msg#: 4204810 posted 8:07 pm on Sep 23, 2010 (gmt 0)

I had trouble understanding your post. Way over my head.

My solution was to add an .htaccess file in the same directory as wordpress, and with the following:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine Off

</IfModule>

# END WordPress

Works for me.

mkingsle

5+ Year Member



 
Msg#: 4204810 posted 8:15 pm on Sep 23, 2010 (gmt 0)

Ahhh... works until i want to change the permalink structure. Nag dabit!

Any help would be appreciated.

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4204810 posted 1:13 pm on Sep 24, 2010 (gmt 0)

You really need to identify the specific problem first, before "trying" a bunch of fixes. Otherwise, this is like pouring more oil into the top of the engine instead of fixing the leak that's causing the oil to run out every day.

By disabling mod_rewrite in the WP subdirectory, you have disabled all of the rules in the main .htaccess file. And note that I just said *all* of the rules. And this appears to "fix" most of your problems. The question is, "Why?"

Knowing the answer to that will lead you to a more correct and likely a more elegant solution.

The rule that you posted about invokes a redirect to remove the .php file extension from URL-paths which are requested directly by clients (only). It will not be invoked as a result of any internal rewrites. So this is evidence that your WP code is publishing links to URLs ending in .php (which is also incorrect), and further, that it requires those links to end in .php and won't work without them. It also implies that the rule which rewrites requests to the WP script may have a flaw, but that rule is not posted here, so I cannot comment further.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved