How can I redirect domain.com/engine.php?v=917XOk1u1B0 to domain.com/watch?v=917XOk1u1B0 via htaccess my current working htaccess code is here.
RewriteEngine on
RewriteRule ^watch/(.*)?$ engine.php?v=$1 [L]
Try:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^v=(.+)$
RewriteRule ^watch/?$ /engine.php [QSA,L]
This will redirect
domain.com/watch?v=12345
to
domain.com/engine.php?v=12345
Related
I want to redirect all URL's such as
example.com/blog/product.php
to
example.com/product.php
I.e. if the URL contains /blog and ends in .php I want to redirect to the URL with /blog removed.
How would I go about doing this?
Thanks
Inside /blog/.htaccess you can have this code:
RewriteEngine On
RewriteRule ^([^./]+)\.php$ /$1 [L,NC,R=301]
If /blog/.htaccess doesn't exist then in your root .htaccess you can have this rule:
RewriteRule ^blog/([^./]+)\.php$ /$1 [L,NC,R=301]
Try :
RewriteEngine on
RewriteCond %{REQUEST_URI} /blog/(.*)\.php$
RewriteRule ^.* /%1.php [R,L]
I am trying to redirect old url to new url but it is not redirecting.
Old url: http://domain.com/STACK/App/
New url: http://domain.com/stack-app
And my .htaccess file
Redirect 301 /STACK/App http://domain.com/stack-app
Thanks,
Try this code.
RewriteEngine on
RewriteRule http://domain.com/STACK/App/ /http://domain.com/stack-app [R=301,L]
For more help go to this link:--
http://edward-designer.com/web/htaccess-url-rewrite-simplified/
You can use this rule as your very first redirect rule in your root .htaccess:
RedirectMatch 301 ^/STACK/App/?$ /stack-app
Within the mod_rewrite section of your .htaccess file, add the following lines on the old site:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com\STACK\App\$
RewriteRule (.*)$ http://domain.com/stack-app/$1 [R=301,L]
</IfModule>
you can use the following code to redirect your website using .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
RewriteRule ^(.*)$ http://www.newexample.com/$1 [L,R=301]
for non www version, you can use the following,
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
RewriteRule ^(.*)$ http://newexample.com/$1 [L,R=301]
I have domain.com/forums but I need help redirecting the forums to sub.domain.com
Below works but I end up with
sub.domain/forums/topic-name-here
RewriteEngine on
RewriteRule ^(.*)$ http://sub.domain.com/$1 [R=301,L]
Try this:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^\/?forum\/.*
RewriteRule ^\/?forum\/(.*)$ http://sub.domain.com/$1 [R=301,L]
P.S. i using "/?" because i forget REQUEST_URI format :(
I am trying to rewrite my .htaccess file to redirect old dynamic URLS to new ones.
I have tried these so far but they are not working as expected. The second rule seems to redirect to the first one.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ "http\:\/\/www\.mydomain\.com\/$1" [R=301,L]
Redirect 301 /product.php?l=old-product-name1 http://www.mydomain.com/product.php?l=new-product-name1
Redirect 301 /product.php?l=old-product-name2 http://www.mydomain.com/product.php?l=new-product-name2
Can anyone help me redirect these properly?
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ "http\:\/\/www\.mydomain\.com\/$1" [R=301,L]
RewriteCond %{QUERY_STRING} =l=old-product-name1
RewriteRule ^product.php$ http://www.mydomain.com/product.php?l=new-product-name1 [R=301]
I use 301 redirect from non-WWW to WWW domain! Works fine, but links are different.
Example:
from - ggkj.com/posts/godzilla/43
to - www.ggkj.com/index.php?view=posts&author=godzilla&aid=43
my .htaccess 301 redirect code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^(.*) http://www.example\.com/$1 [L,R=301]
.htaccess code: http://pastebin.com/t3FA59uq
This is currently what i use on my website with success:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} !^www.walterbax.ca [NC]
RewriteRule ^(.*)$ http://www.walterbax.ca/$1 [R=301,L]
EDIT: after looking into your question a little further I can tell you that your issue is improperly placed in the file. it must be hitting another rule that is rewriting it into URL variables.
I would start with a basic htaccess for the www. rule for testing and add to it from there.
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com$
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]