1

The .htaccess we have in our document_root directory is as follows:

RewriteEngine on

RewriteRule ^posts/1/first-post-title$ /posts/1.html [L]
RewriteCond %{REQUEST_URI} ^/posts/1
RewriteCond %{REQUEST_URI} !/^posts/1/first-post-title$
RewriteRule (.*) posts/1/first-post-title [R=301,L]

The configuration is designed so that the following URLs will all point to "http://localhost/posts/1/first-post-title":

The second line works fine and "http://localhost/posts/1/first-post-title" looks at /posts/1.html

Unfortunately, when either of the other to URLs are used, the user gets redirected to "http://localhost/path/to/document_root/posts/1/first-post-title"

1 Answer 1

2

Change your rewrite to be absolute, e.g. rather than this:

 RewriteRule (.*)  posts/...

Use this:

 RewriteRule (.*)   /posts/...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .