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]
Related
I have searched all over Stackoverflow and Googled wide and far, but I cannot get this seemingly simple task done.
I'm trying to set a rule in htaccess to clean the URL by removing the query string, but leaving its value intact:
http://example.local/?p=subscribe
Becomes:
http://example.local/subscribe
I have tried these various methods:
RewriteEngine on
RewriteCond %{QUERY_STRING}
RewriteRule (.*) /$1? [R=301,L]
or,
RewriteCond %{QUERY_STRING} ^p=$ [NC]
RewriteRule ^(/?)?$ $1? [R=301,L,NC]
or,
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?([^\ ]+)
RewriteRule ^$ /%1? [R=301,L]
But nothing works!
Any help will be greatly appreciated.
Have it like this in your .htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/([^?]*?)/?\?p=([^\s&]+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w-]+)/?$ ?p=$1 [L,QSA]
You can use % to retrieve a rewriteCond Variables
RewriteCond %{QUERY_STRING} ^p=(.*)$ [NC]
RewriteRule ^(.*)?$ %1? [R=301,L,NC]
Will convert any url http:/site.com/url?qs to http:/site.com/qs
I have a page which has a link as:
http://www.example.com/listings.php?packageType=luxury-travel
Which I'd like to send to:
http://www.example.com/luxury-travel
And also:
http://www.example.com/listings.php?packageType=luxury-travel&packageTypeSub=remote-luxury-retreats
To go to:
http://www.example.com/luxury-travel/remote-luxury-retreats
I have used:
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /listings.php?packageType=$1&packageTypeSub=$2 [L]
Which ends up affecting other pages which I have such as:
http://www.example.com/about-us
I have also tried placing:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Before. Also tried playing with:
RewriteCond %{QUERY_STRING} ^packageType=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &packageType=([^&]+) [NC]
RewriteRule ^([^/]*)$ /listings.php?packageType=$1 [L]
Which just give me a 404 error on both links. Anyone have any ideas? Would have thought this would have been a simple one!
In your .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^\.*]+)/([^\.*]+)/?$ listings.php?packageType=$1&packageTypeSub=$2 [L,QSA]
RewriteRule ^/?([^\.*]+)/?$ listings.php?packageType=$1 [L,QSA]
Try this:
RewriteEngine on
RewriteCond %{THE_REQUEST} \ /+listings\.php\? [NC]
RewriteCond %{QUERY_STRING} (?:^|&)packageType=([^&]+)&packageTypeSub=([^&\s]+) [NC]
RewriteRule ^ /%1/%2? [R=301,NC,L]
RewriteRule ^([^/]+)/([^/]+)?$ /listings.php?packageType=$1&packageTypeSub=$2 [L]
Note that if only packageType is available, the rules would redirect to http://www.example.com/luxury-travel/ (note the / at the end) to help differentiate it from links like http://www.example.com/about-us.
If that's not an option, then you would have add rules that specifically provide page/link names.
I have edited and removed some of the development code as it wasn't working.
After a lot of headscratching I finally found a solution which works:
# Rewrite specific pages - listings
# Allow packageType
RewriteCond %{THE_REQUEST} \ /+listings\.php\? [NC]
RewriteCond %{QUERY_STRING} (?:^|&)packageType=([^&]+) [NC]
RewriteCond %{QUERY_STRING} !&packageTypeSub=([^&]+)
RewriteRule ^ /%1/? [R=301,NC,L]
# Allow packageTypeSub
RewriteCond %{THE_REQUEST} \ /+listings\.php\? [NC]
RewriteCond %{QUERY_STRING} (?:^|&)packageType=([^&]+)&packageTypeSub=([^&\s]+) [NC]
RewriteRule ^ /%1/%2? [R=301,NC,L]
# Ignore the images folder allowing images to display
RewriteCond %{REQUEST_URI} !(upload-images) [NC]
RewriteRule ^([^/]+)/([^/]+)?$ /listings.php?packageType=$1&packageTypeSub=$2 [L]
The main issue was the upload-images folder which contains all the images for the site packages was being blocked. I managed to exclude this folder from the rewrite rules and it now seems to be working. Thanks all for your help. Hope this helps someone else in future.
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]
Was trying to rewrite the URL of a page that has multiple parameters and one of the parameters contains multiple words (separated by spaces when submitted).
This would be the URL: www.ABCD.com/store/itemsDescr.php?categ=headbands&id=123&name=brown%20with%20black
I would like the URL to show like this:
www.ABCD.com/store/headbands/123/brown-with-black
I tried this, but it did not work:
RewriteCond %{QUERY_STRING} ^categ=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &categ=([^&]+) [NC]
RewriteRule ^store/itemsDescr\.php$ $0/%1
RewriteCond %{QUERY_STRING} ^id=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &id=([^&]+) [NC]
RewriteRule ^store/itemsDescr\.php/[^/]+$ $0/%1
RewriteCond %{QUERY_STRING} ^name=([^&]+) [NC,OR]
RewriteCond %{QUERY_STRING} &name=([^&]+) [NC]
RewriteRule ^store/itemsDescr\.php/([^/]+/[^/]+)$ http://www.ABCD.com/store/$1/%1/? [L,QSA,NC]
Any help would be much appreciated!
NOTE: Before this rule I want to implement, I already have this other rule for another page, in case it can create conflict:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(store)/index\.php\?categ=([^\s]+) [NC]
RewriteRule ^ /%1/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^store/(.+?)/?$ /store/index.php?categ=$1 [L,QSA,NC]
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 %{QUERY_STRING} ^categ=([^&]+)&id=([^&]+)&name=([^&]+)$ [NC]
RewriteRule ^(store)/itemsDescr\.php$ /$1/%1/%2/%3? [R=302,L,NC,NE]
RewriteRule ^(store)/([^\s]+)\s([^\s]+)$ /$1/$2-$3 [R=302,L,NC]
RewriteRule ^(store)/([^\s]+)\s(.+)$ /$1/$2-$3 [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(store)/([^/]+)/([^/]+)/ /$1/itemsDescr.php?categ=$2&id=$3 [L,QSA,NC,NE]
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]