I want to insert a WordPress blog in a website which is programmed in PHP and that uses includes() to select what content to show, and that uses .htaccess Rewrite Rule to get friendly URLs.

The problem is that when installing WordPress in a subdirectory the rewriteRule executes and doesn't let the user get to the subdirectory where WordPress is located.

One way to solve this could be trying to program the includes to include all the WordPress content, but I think it would be quite difficult (wouldn't it?). Advantage: CSS style preserved!

The other solution I thought about was disabling the Rewrite Rule for the WordPress subdirectory (is it possible? How can it be done?). Disadvantage: CSS nod preserved, should be reinserted modifying WordPress files.

The third way I see is to install WordPress in a subdirectory, although I don't want to use this due to SEO optimization.

.htaccess file:

\# Activar RewriteEngine
RewriteEngine on

\# When only 1 var is set in the url
RewriteRule ^([a-zA-Z0-9\-]+)/?$ index.php?lang=$1

\# When 2 vars are set in the url
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)?$ index.php?lang=$1&link0=$2

\# When 3 vars are set in the url
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ index.php?lang=$1&link0=$2&link1=$3

\# When 4 vars are set in the url
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ index.php?lang=$1&link0=$2&link1=$3&link2=$4

\# When 5 vars are set in the url
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ index.php?lang=$1&link0=$2&link1=$3&link2=$4&link3=$5

1 Answer 1


You are going to have massive problems if you try to run WordPress out of a directory that also serves up non-WordPress PHP files. Trust me; I did this for several years. You will have add a rule to .htaccess, above WordPress's own, to intercept every single request that shouldn't go to WordPress. If all of the content is of the form /foo-bar-something.php, that's easy. Otherwise, that's a nightmare. Just put it in a different directory/subdirectory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.