Question

I have a client's wordpress site : myexamplesite.wordpress.com which is redirected to myexamplesite.com which hosts an Expression engine website.

I am working on redirecting all pages from myexamplesite.wordpress.com to myexamplesite.com but facing issues in url rewriting on the receiving site.

E.g. Url : http://myexamplesite.wordpress.com/2012/10/02/my-blog-post-1 Same blog post in EE site : http://myexamplesite.com/blog/my-blog-post-1

So I would like to rewrite the incoming url which would be: http://myexamplesite.com/2012/10/02/my-blog-post-1 to http://myexamplesite.com/blog/my-blog-post-1

I am using the following htaccess code:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteRule ^[0-9]+/[0-9]+/[0-9]+/(.*)$ blog/$1 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

I checked the variable at index.php page: $_SERVER["PHP_SELF"] and it shows the following uri: /index.php/blog/my-blog-post-1/my-blog-post-1

the post url segment is repeated. And I am in a fix. I don't have much experience working with .htaccess

My EE installation is hosted on EngineHosting : http://www.enginehosting.com/

Thanks in advance.

Was it helpful?

Solution

You want an L at the end of the [NC]:

RewriteRule ^[0-9]+/[0-9]+/[0-9]+/(.*)$ blog/$1 [NC,L]

But if you are working on redirecting, you probably want this:

RewriteRule ^[0-9]+/[0-9]+/[0-9]+/(.*)$ http://myexamplesite.com/blog/$1 [NC,L,R]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top