I am looking to rewrite all calls to
subdomain.domain.com/video.mp4
to rewrite to
https://s3.amazonaws.com/whatever/video.mp4
How would I do that?
And this is for embedded calls in video players/scripts...
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.com$ [NC]
RewriteRule ^(.+)$ https://s3.amazonaws.com/whatever/$1 [R=301,L]
Assuming you have a dedicated folder for the subdomain, you would just need the following rule:
RedirectMatch 301 /(.*) https://s3.amazonaws.com/whatever/$1
Related
I have two domains in may server, a.com which is my main domain and a.fr which is my redirect domain.
I like when the user enter http://a.fr/dynamicpath/ automatically going to http://a.com/dynamicpath/, is it possible to accomplish this through htaccess?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?a\.fr$ [NC]
RewriteRule ^ http://a.com%{REQUEST_URI} [R=301,L]
I want this page:
http://mystore.com/Login.aspx?ReturnUrl=%2fPages%2fHome%2fUser%2fWish-list.aspx
to
http://mystore.com/en/ukeurope/home
So, I try to write a 301 redirection rule like this:
RewriteRule ^Login.aspx$ en/ukeurope/home? [R=301,L]
but when I want to try this redirection.
It gives me 404 not Found.
P.S. I don't want another one that is
mystore.com/Page/Login.aspx
to be redirected by this 301 redirection rule
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+Login\.aspx?ReturnUrl=\%2fPages\%2fHome\%2fUser\%2fWish-list\.aspx [NC]
RewriteRule ^ /en/ukeurope/home? [R=302,L]
url: http://www.side.com/en/page-1/
I need to redirect to http://www.side.com/page-1/
How to do this using .htaccess file, maybe call php file and parse string( URI )?
You can do that with a simple rule:
RewriteEngine On
RewriteRule ^.*?/(.*)$ /$1 [L,R=301]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^en/(.*)$ /$1 [L,R=301,NC]
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^products/([a-zA-Z]+)/([0-9]+)/$ index.php?product=$1&price=$2
This code makes
http://www.example.com/products/computer/1000
into
http://www.example.com/index.php?product=computer&price=1000.
Is it possible to make
http://www.example.com/scriptName/arg1/val1/arg2/val2/arg3/val3
into
http://www.example.com/scriptName.php?arg1=val1&arg2=val2&arg3=val3?
The user should be able to give an unlimited number of arguments. This way one can have /index.php?page=forum&subforum=subforum"e1=postNo1"e2=postNo43 and so on rewrite /index/page/forum/subforum/subforum/quote1/postNo1/quote2/postNo43
How would the .htaccess code look?
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/([^/]+)/([^/]+)(.*?)/?$ $1/$4?$2=$3 [L,QSA]
RewriteRule ^([^/]+)/$ $1.php [L]
This will forward a URI of /scriptName/arg1/val1/arg2/val2/arg3/val3 to /scriptName.php?arg3=val3&arg2=val2&arg1=val1
I have a list of 301 Redirects like this inside htaccess:
Redirect 301 /oldpage1.php http://www.domain.com/newpage1.php
Redirect 301 /oldpage2.php http://www.domain.com/newpage2.php
Redirect 301 /oldpage3.php http://www.domain.com/newpage3.php
...
Now these pages shall be redirected only for a certain domain (there are other domains now pointing to the same location like www.domain.com).
E.g. www.domain.com/oldpage1.php shall be redirected, but www.sub.domain.com/oldpage1.php not.
So whats the way to apply these redirects only for www.domain.com?
Thanks.
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule ^oldpage1\.php/?$ newpage1.php [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule ^oldpage2\.php/?$ newpage2.php [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule ^oldpage3\.php/?$ newpage3.php [L,R=301]
PS: If you have several rules like above then it is much better to use RewriteMap.