i'm really unable to understand how to handle this..
I have this URL: mywebsite.com/product_search.aspx?area=6&category=46
i want to redirect all request to
mywebsite.com
i have tried something like: RewriteRule ^product_search.aspx(.*)$ / [L] and RewriteRule ^product_search.aspx([^/]+)$ / [L], but they are not working or redirect the page to mywebsite.com/area=6&category=46
Anyone can help me ?
Thanks.
As my comment above, .aspx is on Windows, mod-rewrite is an apache module, are you using apache in Windows?
This will be a first approach for apache server, instructions to be inserted in .htaccess or vhosts or equivalent:
RewriteEngine On
RewriteRule ^product_search\.aspx$ / [R=301,L]
It performs a redirection like this:
mywebsite.com/product_search.aspx?area=6&category=46
=> mywebsite.com/?area=6&category=46
Go get rid of all URL arguments, you can append ? at the end of the result URL:
RewriteEngine On
RewriteRule ^product_search\.aspx$ /? [R=301,L]
Related
I need to change the pattern of my url from the normal path into a subdomain. I tried write the .htaccess but it's not work.
http://hello.com/sos/article.php?id=1&title=this-is-a-title.php
From the url above I want to:
Change the pattern to call the page so I remove sos before the domain as a subdomain. So I'd got http://sos.hello.com/
I need the variable to be replaced with forward slash and suffixed with .sos. As the story is about warning : article/1/this-is-a-title.sos
I wish I could have something like this:
http://sos.hello.com/article/1/this-is-a-title.sos
So I wrote :
RewriteEngine On
RewriteRule ^article/([^/]*)/([^/]*)\.sos$ /article.php?id=$1&title=$2 [L]
And guess what! It's not work. Please point me out. What I've done wrong???
I've got the answer after several tries:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.hello.com
RedirectMatch 301 ^/sos/$ http://sos.hello.com/mypage.php
RewriteRule ^article/([^/]*)/([^/]*)\.sos$ /article.php?id=$1&title=$2 [L]
save as .htaccess to the subdomain directory
I want to have a redirect using mod_rewrite.
When someone opens http://aswt.mobileworldindia.com
then they will be automatically redirected to http://www.mobileworldindia.com/panels/mobile/index.php?subdomain=aswt
Please note that http://aswt.mobileworldindia.com is not an actual subdomain and doesn't exist at all and neither I want to have it. I just want to have a redirect in my site.
Tried following code but didnt work, can anybody tell me where I am wrong.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(.+)\.sellingsellingsold\.co.uk$
RewriteRule ^$ /index.php?subdomain=%1 [L,R=301]
This is uploaded at sellingsellingsold's root and I am trying to open http://aswt.sellingsellingsold.co.uk.
Please help me in getting it sorted. It has been 2 weeks since I am trying to achieve the redirection.
Something like this inside the main server configuration or inside a .htaccess file. Using the server configuration is preferred and more reliable.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(aswt)\.mobileworldindia\.com$
RewriteRule ^$ /panels/mobile/index.php?subdomain=%1 [L,R=301]
If you want to redirect from any possible subdomain instead of just "aswt." use (.+) instead of (aswt).
I'm attempting my first pretty url implementation via mod_rewrite. Just want to check if I'm on the right track. I'm doing it via dev environment.
I'm trying to get www.cysticlife.dev/Profile.php?id=34 to become www.cysticlife.dev/34/Profile
Would the regex mod_rewrite version then be:
RewriteEngine on
RewriteRule ^/([0-9]+)/?/Profile$ www.cysticlife.dev/Profile.php?id=$1 [L]
Thanks in advance.
RewriteEngine on
RewriteRule ^/([0-9]+)/Profile/index.html$ /$1/Profile [R=301,L]
RewriteRule ^/([0-9]+)/Profile/$ /$1/Profile [R=301,L]
RewriteRule ^/([0-9]+)/Profile$ www.cysticlife.dev/Profile.php?id=$1 [L]
The "?/" wasn't needed.
The lines I added makes both www.cysticlife.dev/34/Profile, www.cysticlife.dev/34/Profile*/* and www.cysticlife.dev/34/Profile*/index.html* work (with a 301 "Permanently moved" redirection so only one of the three urls is indexed by search engines).
Sidenote: You don't need to specify the full url for your rewrite. You could easily replace the last one with:
RewriteRule ^/([0-9]+)/Profile$ www.cysticlife.dev/Profile.php?id=$1 [L]
how can i redirect index.php?search= to the base url? I tried it with this code:
redirectMatch 301 ^/index.php?search=(.*) http://www.yoursite.com/
but then the page loops the code if i enter the site domain..
mod_alias does only work on the URL path and not the query:
mod_alias is designed to handle simple URL manipulation tasks. For more complicated tasks such as manipulating the query string, use the tools provided by mod_rewrite.
So try mod_rewrite instead:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^search=(.*)
RewriteRule ^/index\.php$ /? [L,R=301]
Or more general:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^([^&]*&+)*search=([^&]*)
RewriteRule ^/index\.php$ /? [L,R=301]
And if you want to use this rule the .htaccess file in your root directory, remove the leading slash from the patterns.
Try:
RedirectMatch permanent ^/index.php?search=(.*)$ http://www.yoursite.com/
I have rebuilt a website from php into ASP.NET and need to redirect all the old horrible page URL's to the root of the new site - The old site just used index.php and print.php then LOADS of querystring values - So I have the following rules
RewriteRule ^print.php$ http://www.mynewsite.co.uk [R=301,L]
RewriteRule ^index.php$ http://www.mynewsite.co.uk [R=301,L]
Problem I have is it is 301 redirecting but appending all the crappy querystrings to the end of the domain - for example
http://www.mynewsite.co.uk?crap=45&more&7698097987 etc...
How do I tell ISAPI not to take the Querystrings and just redirect to the root URL?
The rules should be like this:
RewriteRule ^print.php$ http://www.mynewsite.co.uk? [R=301,L]
RewriteRule ^index.php$ http://www.mynewsite.co.uk? [R=301,L]
Notice the "?" at the end of substitution.