tubepress url rewrite - .htaccess

Im trying to figure out how to mask all urls on my site to make them "pretty" I would like to replace "tubepress_video" with just "video" and "tubepress_page" to "page" Any help would be greatly appreciated.
Example
http://mydomain.com/?tubepress_video=m3gRH-hPS9I&tubepress_page=1

Do this: This will only work for the links of this format:
http://mydomain.com/?tubepress_video=m3gRH-hPS9I&tubepress_page=1
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^tubepress\_([^&]+)&tubepress\_([^&]+)$ [NC]
RewriteRule ^ ?%1&%2 [L,R=301]
RewriteCond %{QUERY_STRING} !^tubepress [NC]
RewriteCond %{QUERY_STRING} [^&]+&[^&]+
RewriteRule ^ ?tubepress_%1&tubepress_%2 [L]

Related

htaccess 301 redirect joomla URLs with multiple variables

I'm trying to redirect this URL:
https://www.sendmoneypacific.org/index.php?option=com_countries&view=details&Itemid=165&lang=en
to this URL:
https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html
I've tried the following:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^option=com_countries&view=details&Itemid=165&lang=en$
RewriteRule ^/index.php$ https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html? [R=301,L]
and:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} ^option=com_countries&view=details&Itemid=165&lang=en$
RewriteRule ^(.*)$ https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html? [R=301,L]
But neither work. Any help would be greatly appreciated!
I figured it out -
## https://www.sendmoneypacific.org/index.php?option=com_countries&view=details&Itemid=165&lang=en
RewriteCond %{QUERY_STRING} ^option\=com_countries&view\=details&Itemid\=165&lang\=en$
RewriteRule ^index\.php$ https://www.sendmoneypacific.org/pacific-communities/solomon-islands.html? [R=301,L]
If anyone else needs help with this

htaccess RewriteCond using cookie value

I am using below code to redirect the site but its not working. Please suggest me how can I fix the issue.
RewriteEngine On
RewriteCond %{HTTP_COOKIE} site_mobile=desktop; [NC]
RewriteRule ^ http://www.google.com [NC,L]
thanks in advance
I think trailing ; may not be always there. Try this regex:
RewriteEngine On
RewriteCond %{HTTP_COOKIE} (^|\s)site_mobile=desktop(;|$) [NC]
RewriteRule ^ http://www.google.com [R,L]
If that doesn't redirect try this condition (for testing):
RewriteCond %{HTTP_COOKIE} desktop [NC]

Multiple parameters URL redirection to another preety URL

I want to redirect via htaccess:
test.mydomain.com/articles_main.php?post=POSTTILE&name=&email=
To:
mydomain.com/POSTTILE
Any help is greatly appreciated, I have struggled with this for a long time, please help.
EDIT:
I have tested many things but what remained commented is this:
RewriteEngine On
RewriteBase
RewriteCond %{THE_REQUEST} \s/articles_main.\.php\?post=([^&]*)&name=([^&]*)&email=([^&]*) [NC]
RewriteRule ^articles_main\.php\?post=([A-Za-z0-9-]+)&name=&email=$ http://mydomain.com/$1 [L,R=301]
RewriteRule ^articles_main\.php\?post=([A-Za-z0-9]+)&?$ ^/$1/?$ [R=301]
Your regex is not correct. Use this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.mydomain\.com$ [NC]
RewriteCond %{THE_REQUEST} \s/articles_main\.php\?post=([^&]+)&name=([^&]*)&email=([^&\s]*) [NC]
RewriteRule ^ http://mydomain.com/$1? [L,R=301]
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^([A-Za-z0-9]+)/?$ articles_main\.php?post=$1name=&email= [L,QSA]

match query string variables with mod_rewrite?

The site I am trying to work on is http://northidahocvma.org/2GD/index.php?page=1
So suppose I have URLs with query string parameters like these:
/index.php?page=1
Using mod_rewrite, how can I redirect them to URLs like these?
/page/1 or /1/
I was given this code but still cant quite figure it out
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /page/%1? [R=302,L]
RewriteRule ^page/([^/.]+)/?$ /index.php?page=$1 [L,QSA,NC]
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /page/%1? [R=302,L]
RewriteRule ^page/([^/.]+)/?$ /index.php?page=$1 [L,QSA,NC]

htaccess remove ?category_id=xxxNumbers

I need your help after to check everywhere. Because Google Webmaster Tools view them as the duplicate Titles and Descriptions.
I need to remove some of parameters from my complex URL.
FROM:
http://3dstreaming.org/3d-media/videos/7006-avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn.html?category_id=567
TO:
http://3dstreaming.org/3d-media/videos/7006-avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn.html
where "7006-avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn.html"
7006=variable value
avatar-3d-2009-half-sbs-full-hd-1080-dual-hdf-orn=variable words
and remove ?category_id=567 ("?category_id=xxxNumbers")
and then the same for the following parameters:
"?start=xxxNumbers"
"?filter_tag=xxxWords"
"?pattern=xxxWords"
Could someone help me?
Thanks in advance
I tried with this but doesn't work:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.+?&)category_id=[^&]*(.*)$
RewriteRule ^(index\.php)?$ %{REQUEST_URI}?%1%2 [R=301,L]
Adding the following to your htaccess should achieve what you are looking for
RewriteEngine on
RewriteCond %{THE_REQUEST} \?category_id= [OR]
RewriteCond %{THE_REQUEST} \?start= [OR]
RewriteCond %{THE_REQUEST} \?filter= [OR]
RewriteCond %{THE_REQUEST} \?pattern=
RewriteRule ^ %{REQUEST_URI}?%1 [L,R=301]
OR
adding the following will remove ALL parameters from a url
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /([^\?\ ]*)\?
RewriteRule ^ /%1? [L,R=301]

Resources