Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule with [P] line not performing as desired

         

projects77

4:43 pm on Apr 18, 2016 (gmt 0)

10+ Year Member



Hi, new here. Thanks for reading.

I'm using this:
RewriteRule "^special_folder/(.*)$" "http://my_new_domain.com/$1" [P]

With this it will reference/use (but keep hidden) the my_new_domain.com when I am in my_old_domain.com/special_folder/ and that is all well and good.

However, when i click on a link to a deeper folder in wordpress (for example: my_old_domain.com/special_folder/dir1/dir2/dir3/ it loses the mask and shows my_new_domain.com/deeper_folder which i dont want it to do. I want it to keep the mask and display my_old_domain.com/special_folder/even_more_special_folder

Perhaps I can modify this existing line to cover all subdirectories. Any better ideas or suggestions?

Additionally, I need the links on my site to not point towards my_new_domain.com ever, but to of course continue to point towards my_old_domain.com/special_folder/ ... is that possible?

lucy24

9:18 pm on Apr 18, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<tangent>
Get rid of all quotation marks. You don't need them. (I can't think of any situation where quotation marks are needed in a RewriteRule. Only rarely in a RewriteCond.)
</tangent>

The first explanation that comes to mind is that you've got more than one htaccess file-- specifically, more than one use of mod_rewrite-- along the same (physical) path. This is iffy at the best of times; even "RewriteOptions inherit" may not work the way you'd hoped it would. So check this carefully before we look for anything more complicated.

Does the RewriteRule ever work as intended?

Where is this rule located, relative to the WordPress rules? Before, I hope. The docs say that [P] implies [L]-- but then, they also say this about [PT], though it isn't necessarily so. Many things are different in htaccess. So also double-check that nothing changes if you add an explicit [L].