質問

I'm trying to use the wordpress plugin Redirection to redirect a url like:

http://mysite.com/wp-content/uploads/image.jpg to

http://mysite.com/subdir/wp-content/uploads/image.jpg

I'm trying /(wp-content/uploads/.*) and finding that it redirects to:

http://mysite.com/subdir/subdir/subdir/subdir/subdir/subdir....

and throws an error in Firefox: 'Firefox has detected that the server is redirecting the request for this address in a way that will never complete.'

I've also tried:

^https?://(|www\.)mysite.com.au/(wp-content/uploads/.*)

but it seems that redirection doesn't work with the domain - the page loads with a 404, and the URL is not altered.

Any clues appreciated!

Thanks, Tim

役に立ちましたか?

解決 2

Changed the rule to ^/wp-content..

additionally, I think the rule was actually interacting with another rule, which seems to be solved by moving my rule to run first, although there's nowhere to specify [L]

In future, when i've kept an eye on the logs to see if I'm getting it right, I'll move the redirects into .htaccess and use the [L] flag @jason suggested.

他のヒント

You need to specify the [L] flag for your rewrite to ensure it's the last. Otherwise, it keeps rewriting your URL, appending subdir every time.

I am not familiar with the Redirection plugin. See if it has this option. If not, I'd suggest a more specific regex or dropping the plugin and writing these yourself, directly in .htaccess.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top