I ins开发者_运维问答talled wordpress in a subdirectory, lets say www.example.com/wordpress. I want the user to hit www.example.com and see the index of www.example.com/wordpress. I'm already using a custom pretty permalinks structure /%category%/%pagename%/ so the htaccess file is a little foreign to me.
My current htaccess file looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
I've tried numerous solutions from browsing across the web but nothing seems to work. I either get internal 500 errors or view previous pages in the root directory like example.com/about (even though I've deleted the original about.html in the root) even after I deleted my cache.
Any help you could give would be extremely helpful. Thanks for your time, Rob
The .htaccess file needs to be located in / and not in /wordpress/ and RewriteBase should be / not /wordpress/. Leave the permalinks setup on, but don't use an .htaccess file in /wordpress/. You'll need to set the root directory in your wordpress install to / and setup redirects for /wordpress/wp-content/ and the other wordpress subdirs in /.htaccess so that requests to those directories are also forwarded correctly.
I assume that you want to set up wordpress this way because there are other directories not associated with the wordpress install that you want to be accessible from / (www.example.com/cgi-bin/ for example). You'll need to set up your .htaccess file in / to make any directory aliases (like /cgi-bin/) accessible so requests to /cgi-bin/ don't get redirected to wordpress.
EDIT: I haven't done something like this in a long time, but here's my best guess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/(.*)$ /wordpress/wp-content/$1 [L,QSA]
RewriteRule ^wp-admin/(.*)$ /wordpress/wp-admin/$1 [L,QSA]
RewriteRule ^wp-include/(.*)$ /wordpress/wp-include/$1 [L,QSA]
RewriteCond %{REQUEST_URI} !^/yourAliasUnrelatedToWordpress [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L,QSA]
</IfModule>
精彩评论