0

A WordPress site under development. The goal is to take what looks like permalinks (but are not), pass the relevant bits to a static page via URL parms.

A direct test of the static pages works (forgive the unfinished output):

http://test.cynical.ws/display-murphy/?cynical_id=_Computing's_7th_law

The common URL for this page should be:

http://test.cynical.ws/murphyism/_Computing's_7th_law

The RewriteRule I have in place, but which is failing is:

RewriteRule ^murphyism/(.*)$ display-murphy/?cynical_id=$1

Since the direct access to the static page does not produce an error, I doubt it is a mageling of the single quote mark (and the database from which we look-up content has a lot of kets with single quotes).

I have tried various RewriteRule flags (such as [L]) with no change in behavior.

Here is the entirety of the htaccess file:

RewriteEngine on

RewriteRule ^murphyism/(.*)$ display-murphy/?cynical_id=$1

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
wp78de
  • 18,207
  • 7
  • 43
  • 71

1 Answers1

0

Regarding RewriteRule, as discussed, use:

RewriteRule ^murphyism/(.*)$ display-murphy/?cynical_id=$1 [NE,R,L] 

The important part here is the NE|noescape since the target URL contains a fragment. You need to use the NE flag to avoid URL escaping issues


Regarding the rewrite without redirect, this requires enabling mod_proxy and mod_rewrite in Apache's httpd.conf.

Then, the rewrite should look like this:

Options +FollowSymLinks -MultiViews 
RewriteEngine On
RewriteRule ^murphyism/(.*)$ display-murphy/?cynical_id=$1 [NC,NE,L]

Reference:

wp78de
  • 18,207
  • 7
  • 43
  • 71
  • Thanks, and sorry for the late reply. It would appear that the example above is for another site+condition (mainly removing the /en/ from the URL). So, taking a guess, I composed the following. Neither the remaining RewriteRule or the one commented-out worked. RewriteCond %{REQUEST_URI} ^/murphyism$ RewriteRule ^murphyism/(.*)$ display-murphy/?cynical_id=$1 [NC,L] #RewriteRule ^(.*) display-murphy/?cynical_id=$1 [NC,L] – user3277069 May 27 '18 at 23:38
  • Sorry, just realized I confused NC and NE. Updated answer. Use a new browser and incognito-mode to try updated rule. – wp78de May 28 '18 at 20:03
  • Thanks again. 1) This does indeed preserve the original URL in the browser (though someone sles pointed out that flag QSA does the same). 2) Big problem remains now within Wordpress. It strips any single quote marks, which them causes the database look-up to fail. I have not yet found a way (aside from hacking the core Wordpress code) to have it not do so. – user3277069 May 29 '18 at 20:57