It seems a very eask task, but I couldn't make it for hours after reading too much tutorial. Please help..
I need to redirect
http://example.com/myfolder/myfile.php?type=1&add=20
to this address:
http://example.com/newfolder/mytasks.xml
I tried too many. My last tryout was this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/myfolder/myfile.php?type=1&add=20$ /newfolder/mytasks.xml [R=301,NC,L]
</IfModule>
Use this rule instead:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+myfolder/myfile\.php\?type=1&add=20 [NC]
RewriteRule ^ /newfolder/mytasks.xml [R=301,L]
Remember:
RewriteRule match doesn't start with a slash /
RewriteRule doesn't match query string, it matches only Request URI
If you also want the query type=1&add=20 removed, something like this should work:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} type=1&add=20 [NC]
RewriteCond %{REQUEST_URI} !/newfolder/ [NC]
RewriteRule ^myfolder/myfile\.php /newfolder/mytasks.xml? [R=301,NC,L]
Redirects:
http://example.com/myfolder/myfile.php?type=1&add=20 to
http://example.com/newfolder/mytasks.xml
For silent mapping, replace [R=301,NC,L] with [NC,L]
Related
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>
I guess it's an easy question but I hardly know syntax used in .htaccess, so I got a bit stuck. How to add '/de/' after a domain name in this case, so the result will be something like 'blablabla.com/de/blog' or 'blablabla.com/de/offices' instead of 'blablabla.com/blog' and 'blablabla.com/offices'?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} lang=de [NC]
</IfModule>
I know that there should be RewriteRule after RewriteCond but, as I've said before, I'm not familiar with the syntax...
You can use:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_COOKIE} lang=de [NC]
RewriteCond %{REQUEST_URI} !^/de/ [NC]
RewriteRule ^(.*)$ /de/$1 [R,L]
</IfModule>
To access your site urls with /de segment ,you can use :
RewriteEngine On
RewriteBase /
RewriteRule ^de/(.+)$ /$1 [NC,L]
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]
trying to redirect this query to a new domain:
www.domain.com/search.php?q=keyword
to
www.newdomain.com/search.php?q=keyword
keyword can be any word
And want to keep the rest in domain, I just need to redirect this query.
I try several ways and the one I found closer to solution is this one:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^q=1$
RewriteRule ^search\.php$ http://www.newdomain.com/search.php?q=$1 [R=301,L]
but does not work!
Hope someone could help me correcting this and also if this is the best way to do the job?
Many thanks.
You're pretty close.
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$ [NC]
RewriteCond %{QUERY_STRING} ^q=.+ [NC]
RewriteRule ^(search\.php)$ http://www.newdomain.com/$1 [R=301,L,NC]
Try this
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=123$
RewriteRule ^/?product\.php$ http://website.com.au/product_123.php? [L,R=301]
Or
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=([^&]+)
RewriteRule ^/?product\.php$ http://website.com.au/product_%1.php? [L,R=301]
this works and is simple
RewriteEngine on
RewriteRule ^(.*)$ http://newdomain.com/$1 [QSA]
I'm trying to redirect article.php?title=variable to variable/ using .htaccess but I'm not really sure what is wrong with my code. If I go to http://site.com/variable/ it is redirecting me to http://site.com/article.php//?titlu=article.php
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
#Rewrite urls for article
RewriteRule ^(.*)/$ article.php?titlu=$1
RewriteRule ^(.*)$ /$1/ [R]
</IfModule>
You have to capture the query string. This should work for you.
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} title=([A-Za-z0-9_.-]*)
RewriteRule ^article.php /%1/? [R=301,L]
I'm assuming you don't want to redirect slashes... if you do you could add them to the string as well (or accept all characters).
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} title=(.*)
RewriteRule ^article\.php /%1/? [R=301,L]