0

I'm using the Rewrite Plugin from the Wordpress plugin site here: Wordpress Plugin Page

I'm trying to get the following URL homes-for-sale-details/4420/217007490/177/Fb-landing-page to pull up a custom PHP page in the subdirectory propertylisting1. So this is my rule:

^homes-for-sale-details/4420/217007490/177/Fb-landing-page(.*)$

And I have it redirecting to propertylisting1/index.php

It seems to work because when I go to that URL it actually detects it, but it doesn't display the page I want it to display, it redirects me to the home page, completely redirects me.

enter image description here

I have the rule at the top also.

  • I don't know anything about that plugin, but it probably only deals with the internal rewrite system, where rules can only point to the main index.php file with the necessary query vars to load a WordPress object. Those are parsed in php, not by apache. – Milo Aug 18 '17 at 3:57
0

The answer is to not use plugins, just use Apache's built in HTAccess. The trick with HTAccess and Wordpress so as not to break wordpress rewrite features, is to place the new rule before the RewriteCond statement of wordpress. So the final looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^homes-for-sale-details/4420/217007490/177/Fb-landing-page(.*)$ propertylisting1/index.php?success=$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

As you'll notice, I had to place it in-between the conditions for not found, and the base rewrite rule.

This way works perfectly fine and doesn't break any of Wordpress' own rules in the process.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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