Forum Moderators: phranque
/mydir/wallpapers/myimage1.jpg
/mydir/wallpapers/myimage2.jpg
/mydir/wallpapers/myimage3.jpg
to my new domain in same dir, so when anybody search for
myolddomain/mydir/wallpapers/myimage1.jpg
goes to
mynedomain/mydir/wallpapers/myimage1.jpg
and if somebody search for image2.jpg same thing.
Is there a way to do that with just 1 line in .htacess?
RewriteRule ^http://www.mydomain/mydir/wallpapers/(.*)$ [mynewdomain...] [R=301,L]
Tried putting the string at bottom, top and middle. And nothing, allways 404 error.
Is that dependant of any apache version?
Do not include the domain in the rule's URL-pattern; It should work exactly as I posted it.
Do you have any other working mod_rewrite rules in this .htaccess file?
If not you'll need to precede the rewriterule with the second line below, or both the first and second line:
Options +FollowSymLinks
RewriteEngine on
Completely flush (delete) your browser cache before testing any change to server-side code.
Jim
RewriteEngine on
RewriteRule ^/simpsons-photos/wallpapers/(.*)$ http://www.example.com.ar/simpsons-photos/wallpapers/$1 [R=301,L]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.esp.br(/)?.*$ [NC]
RewriteRule .*\.(gif¦jpg¦jpeg¦bmp¦png)$ - [F,NC]
RewriteCond %{REMOTE_ADDR} ^204\.13\.51\.241$ [OR]
RewriteCond %{REMOTE_ADDR} ^204\.13\.51\.246$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^http://www\.iaea\.org [OR]
I'll try emptying cache...
[edited by: jdMorgan at 6:52 pm (utc) on Mar. 20, 2008]
[edit reason] No URLs, please. See Terms of Service. [/edit]
Let's clean this up:
RewriteEngine on
#
RewriteRule [b]^sim[/b]psons-photos/wallpapers/(.*)$ http://www.example.com.ar/simpsons-photos/wallpapers/$1 [R=301,L]
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?exampl[b]e\.esp\.br[/b] [NC]
RewriteRule [b]\.([/b]gif¦jp[b]e?g[/b]¦bmp¦png)$ - [F,NC]
#
RewriteCond %{REMOTE_ADDR} ^204\.13\.51\.241$ [OR]
RewriteCond %{REMOTE_ADDR} ^204\.13\.51\.246$ [OR]
RewriteCond %{HTTP_USER_AGENT} ^http://www\.iaea\.org [OR]
...
(RewriteRule here to block unwelcome access)
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim