url cleanup with .htaccess rewrite mode url cleanup - .htaccess

i have htaccess problem.
i want use htaccess rewrite mode for change this url:
http://somedomain.com/?id=https://play.google.com/store/apps/details?id=com.supercell.clashofclans
to this:
http://somedomain.com/?id=com.supercell.clashofclans
I've folowed some .htaccess tutorials but I couldn't. How can I make it work?

This should work for you:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=(.*)?id=(.*)
RewriteRule ^$ /?id=%2 [L,R=301]

Related

URL Rewriting with .htaccess redirects

i am trying to Generate
http://example.com/file/1.php?name=the-file-name-any&id=32vr&code=1548393
to
http://example.com/file/the-file-name-any.32vr/1548393
but i am not success
my .htaccess redirect code
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /file/1.php?the-file-name-any=$1&id=$2&code=$3 [L]
Try using this rule:
RewriteEngine On
RewriteRule ^file/([^/]*)/([^/]*)/([^/]*)$ /file/1.php?name=$1&id=$2&code=$3 [L]
Make sure it is at the top of your .htaccess and you've cleared your cache before testing.

How to redirect using htaccess without causing a loop

I can't figure out how to redirect the URL below without causing a loop problem. I would like to redirect this URL ...
http://toffsnew.co.uk/forum/recent
to this ...
http://toffsnew.co.uk/forum/recent?limitstart=0
using htaccess
Thanks
You can use this code in your /forum/.htaccess file:
RewriteEngine On
RewriteBase /forum/
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(recent)/?$ $1?limitstart=0 [L,NC]

Apache Server .htaccess rewrite with wildcard

Is it possible to create a rewrite code that includes a wildcard?
for example any request for:
http://example.com/something1/something2/*
would redirect to:
http://example.com/newthing
AND
will it matter where in the .htaccess file I place the rewrites?
This should work for you:
RewriteEngine On
RewriteRule ^something1/something2/(.*)$ /$1 [R=302,L]
It should change http://example.com/something1/something2/test to http://example.com/test
EDIT:
RewriteEngine On
RewriteRule ^shirts/(.*)$ /clothing.html [R=301,L]

How to rewrite /?custom_ref= with /?ref= using htaccess rewrite

How to rewrite
/?custom_ref=
with
/?ref=
using htaccess rewrite???
RewriteEngine On
RewriteCond %{QUERY_STRING} custom_ref=(.*)
RewriteRule (.*) /?ref=%1 [R=301,L]
Can you please tell me the directory/file that you using this query on so I make sure this code will only work with it.

mod_rewrite 301 redirect not working

I'm trying to set up a rewrite that will redirect this URL:
/video-2011.php?video=150
to this:
/video/150/freeform-title-text-here/
I have the rewrite working using this line in my HTACCESS:
RewriteRule ^video/([0-9]+)/(.*)$ video-2011.php?video=$1 [L]
But as soon I add R=301 into the mix, it breaks. Any ideas?
Here's the full HTACCESS when it breaks:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^video/([0-9]+)/(.*)$ video-2011.php?video=$1 [R=301,L]
Any help is greatly appreciated, thanks!
I think you might be missing a line from your .Htaccess.
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^video/([0-9]+)/([a-z0-9-_]+)$ video-2011.php?video=$1 [L]
#New
RewriteCond %{REQUEST_URI} !^/video/([0-9]+)/([a-z0-9-_]+)/?$
RewriteCond %{QUERY_STRING} ^video=([0-9]+)&name=([a-z0-9-_]+)/?$
RewriteRule ^video-2011.php$ video/%1/%2/? [R=301,L]
I assuming you want to rewrite the url if it is:
/video/150/freeform-title-text-here/
And redirect the url if it is:
/video-2011.php?video=150
to:
/video/150/freeform-title-text-here/
So this way it keeps the urls looking pretty and tidy.
Please correct me if I am wrong.
Edit
I've added in a RewriteCond to stop the second rewrite happening.
As the first rule will obviously rewrite:
/video/150/freeform-title-text-here/
Which means the query string you don't see:
/video-2011.php?video=150
Would of made the second rule happen too.
Can you try:
RewriteRule ^video/([0-9]+)/ /video-2011.php?video=$1 [R=301,L,NC,QSA]
And yes it will redirect /video/150/foo to /video.php?video=150 not the other way around as you've stated in your question.

Resources