markahc
markahc

Reputation: 13

.htaccess weird rewrite behaviour

I'm trying to mask the word 'links' in my urls.

I have the following code that rewrites well and the URL in the address bar is not changed if you visit this url directly:

http://url.com/posts

If the URL is from a link within the site () the url in the address bar is changed from

http://url.com/posts to http://url/links

Here is the Rewrite code I am using:

RewriteRule ^(.*)posts(.*)$ /$1links$2 [P]

Any help is appreciated!

Upvotes: 1

Views: 46

Answers (1)

anubhava
anubhava

Reputation: 785146

Try inserting this rule before your existing rule:

RewriteCond %{THE_REQUEST} \s/+(.*?)links[^\s]* [NC]
RewriteRule ^ /%1posts%2 [L,R,NE]

#existing rule
RewriteRule ^(.*)posts(.*)$ /$1links$2 [L,NC]

Upvotes: 1

Related Questions