2

I'm trying to do an .htaccess redirect from /modules.php?name=Farmtoschool to a new URL.

I've looked at the other posts here but it doesn't seem to work. (full htaccess below, redirect at the bottom)

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
RewriteEngine On
RewriteCond   %{REQUEST_URI}    ^/modules.php$
RewriteCond   %{QUERY_STRING}   ^name=Farmtoschool$
RewriteRule   ^(.*)$ http://mynewdomain.com/modules.php?name=Farmtoschool   [R=301,L]

this is the link that I want to redirect:

http://myolddomain.com/modules.php?name=Farmtoschool

Any ideas? Thanks

3
  • It goes to the WordPress 404 page. Commented Aug 13, 2015 at 21:30
  • Can you post full htaccess and tell which URL is causing 404? Commented Aug 14, 2015 at 0:20
  • Hello anubhava, I've updated with the full htaccess and the url Commented Aug 14, 2015 at 15:55

1 Answer 1

1

Reorder your rules by keeping redirect rule before WP rules:

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^name=Farmtoschool$
RewriteRule ^modules\.php$ http://farmtoschoolbc.ca/modules.php?name=Farmtoschool [NC,R=301,L]

RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^(wp-(content|admin|includes).*) $1 [L]

RewriteRule ^(.*\.php)$ $1 [L]

RewriteRule . index.php [L]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.