.htaccess redirect with question mark - .htaccess

I'm trying this to redirect via .htaccess a this URL
http://www.deguate.com/foros/showthread.php?874-Soy-de-Guatemala-y-quiero-dar-a-mi-bebe-en-adopcion
to this one:
https://www.deguate.com/artman/publish/mujer-actualidad/Soy-de-Guatemala-quiero-dar-mi-bebe-adopcion.shtml
I've tried many options but nothing seems to work, like:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^foros\/showthread\.php\?874\-Soy\-de\-Guatemala\-y\-quiero\-dar\-a\-mi\-bebe\-en\-adopcion$ "https\:\/\/www\.deguate\.com\/artman\/publish\/mujer\-actualidad\/Soy\-de\-Guatemala\-quiero\-dar\-mi\-bebe\-adopcion\.shtml" [R=301,L]

You can use the following rule:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(874-Soy-de-Guatemala-y-quiero-dar-a-mi-bebe-en-adopcion)$
RewriteRule ^foros/showthread\.php$ https://www.deguate.com/artman/publish/mujer-actualidad/%1? [L,R]

Related

I want to redirect query string URL to specific page. adparch.com/*/*pagenumber=* to adparch.com/projects

I got these URLs
https://www.adparch.com/vi/projects/common-wealth-bank/?pagenumber=2
https://www.adparch.com/projects/Technology--It/oppo?pagenumber=2
https://www.adparch.com/vi-VN/ky-thuat-cong-nghe?pagenumber=4
https://www.adparch.com/vi-VN/du-an?pagenumber=8
And They got 1 rule contains characters (?pagenumber). I want to redirect all to https://www.adparch.com/project/
I used .htaccess file for redirecting these URLs
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*$
RewriteCond %{QUERY_STRING} ^pagenumber=(.*)
RewriteRule ^(.*) /project [R=301,L]
But it seems not work.
Thank you so much
I do some cuts in your rules, please check:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} pagenumber=(.*)
RewriteRule ^(.*) /project/? [R=301,L]
</IfModule>

Redirect urls with question mark and other parameters in htaccess

I want to redirect pages like:
/category-name/post-name.html?id=1234
To:
/category-name/1234-post-name.html
How can do this using htaccess?
What I have tried:
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^([^/]+)/([^.]+)\.html$ /$1/%1-$2\.html [L,R=301]
But it is a continuous redirect.
You can use these rules in your site root .htaccess:
RewriteEngine On
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+([\w-]+)/([\w-]+)\?id=([^\s&]+) [NC]
RewriteRule ^ /%1/%3-%2? [R=301,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^([\w-]+)/([^-]+)-([\w-]+)/?$ $1/$3?id=$2 [L,QSA]
Try this
Make sure the url is root url
Example:-
www.foo.com/category-name/post-name.html
It will only work if the project url is same as that of the above.
www.foo.com/blog/category-name/post-name.html
This won't work you need to update the RewriteBase url accordingly l.
This is the conditions
RewriteEngine On
RewriteBase /
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule here
RewriteRule ^category-name/([0-9]+)-post-name$ /category-name/post-name.html?id=$1 [L]
This should work..

removing url parameters from one url using .htaccess codes

I tried lot of combinations using available examples (.htaccess directives), but I couldn't able to achieve what I want. The problem is...
My actual URL is
http://localhost/smon2/custsms/index.php?p_mob=9886419001
What I want is
http://localhost/smon2/custsms/
Please help me in wrinting .htaccess code lines.
Thanks
I tried with few of the items below...
RewriteEngine On
RewriteCond %{QUERY_STRING} ^p_mob=1$
RewriteRule (.*) $1? [R=permanent]
RewriteEngine On
RewriteCond %{QUERY_STRING} "p_mob=" [NC]
RewriteRule (.*) /$1? [R=301,L]
RewriteEngine On
RewriteRule ^/custsms/%{QUERY_STRING}/?$ http : //localhost/smon2/custsms/ [NC,L]
Nothing was working. please help.
Replace all your current rules with this rule:
DirectoryIndex index.php
RewriteEngine On
RewriteBase /smon2/
RewriteCond %{QUERY_STRING} ^p_mob=\d+ [NC]
RewriteRule ^(custsms)/index\.php$ $1/? [R=301,L,NC]

redirect all urls with "videos.php" to base

I'm hoping someone can assist me with a mod_rewrite rule to redirect dynamic urls pointing to "videos.php" on my server to the base url.
For example, I need to redirect 'website.com/1/music/various/videos.php?=1234'
to 'website.com/videos.php?=1234'
edit: I am looking for a dynamic solution. If a url is pointed to videos.php at any time, I need to do a 301 redirect to home directory. Ie if /1/home/music/videos.php?=1234 redirect to /videos.php?=1234, or /music/playlist/1234/videos.php?1432 to /videos.php?1432.
Create a .htaccess file and insert these lines:
RewriteEngine On
# Page moved permanently:
RewriteRule ^videos\.php\?\=([0-9]+)\.html$ /1/music/various/videos.php?=$1 [R=301,L]
When testing, leave out the R=301, part, or you'll only see cache contents for a long, long time. Add it when sure its working fine. Or use 302, which means temporarily.
Please check this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/1/music/various/videos.php$
RewriteCond %{QUERY_STRING} (.+)$
RewriteRule ^(.*) /videos.php [R,QSA]
RewriteCond %{REQUEST_URI} ^/videos.php$
RewriteCond %{QUERY_STRING} !(.+)$
RewriteRule ^(.*) http://%{HTTP_HOST}/ [R=301]
If it's not work, then try this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/1/music/various/videos.php$
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^(.*) /videos.php%1 [R]
RewriteCond %{REQUEST_URI} ^/videos.php$
RewriteCond %{QUERY_STRING} !(.+)$
RewriteRule ^(.*) http://%{HTTP_HOST}/ [R=301]

RewriteRule at htaccess wrong redirect

ive this rules at htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^warcraft$ www.site.com/forumdisplay.php?f=480 [R=301,NE,NC,L]
issue happend when redirect warcraft its redirect to
http://www.site.com/home/site/public_html/www.site.com/forumdisplay.php?f=480
any tip ?
I suppose you want to redirect it to http://www.site.com/forumdisplay.php?f=480
If so put it in your .htaccess file:
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^warcraft$ http://www.site.com/forumdisplay.php?f=480 [R=301,NE,NC,L]
You must provide the full URL including protocol in your rule, in this case http://www.site.com/.....

Resources