Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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