Redirect complete url to another url - apache

Actually i have changed my dynamic urls to static urls. But the strange thing is i have some old urls which are dynamic. Among them the url is http://www.startonlinegames.com/download.php . I want this url to redirect to http://www.startonlinegames.com/download/?page=download .. for this i have added the following htaccess rule in my htaccess file.
Redirect http://www.startonlinegames.com/download.php http://www.startonlinegames.com/download/?page=download
but its not working...can anyone suggest me.

Try this : and let me know if it works otherwise will try for another
Options +FollowSymlinks
RewriteEngine on
rewriterule ^download.php(.*)$ http://www.startonlinegames.com/download/?page=download$1 [r=301,nc]

Related

RedirectMatch adding extra url segments

I'm trying to redirect requests for our old blog to a new url on a subdomain.
The old url looks like
https://www.website.com/blog-name/post/slug-of-the-title
and it needs to redirect to
https://stage.website.com/blog-name/slug-of-the-title
I'm using this rule in my .htaccess
RedirectMatch ^/blog-name/post/(.*)$ https://stage.website.com/blog-name/$1
And I'm getting redirected to the correct page, but my urls have extra segments on the end. Like
https://stage.website.com/blog-name/slug-of-the-title/?/blog-name/post/slug-of-the-title
What am I doing wrong?
With your shown samples, could you please try following. Please clear your browser cache before testing your URLs. Make sure you keep these rules at the top of your .htaccess rules file(in case you have any more rules also in your .htaccess file).
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)?website\.com$ [NC]
RewriteRule ^blog-name/post/(.*)/?$ https://stage.website.com/blog-name/$1? [NC,R=301,L]

htaccess for URLS

Can anyone let me know how i can redirect all urls so they include a new path.
For example, on my old site i have a urls like this:
http://www.example.com/tag/tag-title1/
http://www.example.com/tag/tag-title2/
http://www.example.com/tag/tag-title3/
I now need all of these to be redirected to:
http://www.example.com/waterblog/tag/tag-title1
http://www.example.com/waterblog/tag/tag-title2
http://www.example.com/waterblog/tag/tag-title3
So really all i need to do is add /waterblog/ before the /tag/ on all URLS.
Thanks
You can use this .htaccess:
RewriteEngine on
RewriteRule ^((?!waterblog/).*)$ waterblog/$1 [NC,R,L]
So really all i need to do is add /waterblog/ before the /tag/ on all URLS.
You can use this simple rule in your root .htaccess:
RedirectMatch 302 ^/(tag/.*)$ /waterblog/$1

rewrite engine is removing slashes from my urls

I have looked everywhere and spent hours trying to get this working, but I have been unsuccessful. I could really use some help.
I am not an expert with apache but I have an old URL and am trying to redirect all my old pages to my new URL. My old URL is:
www.bc-mortgage-brokers.ca
My new URL is
http://bc-mortgage-broker.ca
The home page redirects correctly, but it is the only one to do so. For example, if I type:
www.bc-mortgage-brokers.ca/16/
into my browswer, it removes the slashes and then fails to redirect. I will get this url instead:
bc-mortgage-broker.ca16
in my .htaccess file, I have the entry for this particular one as:
redirect 301 /16/ http://bc-mortgage-broker.ca/16/
My header for the file is currently:
Options +FollowSymLinks
RewriteEngine on
I am creating the file in textmate.
When I look at the error logs, I read:
RewriteCond: bad flag delimiters
Use this rule in your root .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(16(?:/.*)?)$ http://bc-mortgage-broker.ca/$1 [L,R=301]

Rewrite friendly URL not work by click on link

I'm trying to rewrite my website URL to more friendly URL, for example:
www.mysite.com/profile.php
to
www.mysite.com/profile
so far I'm able to do it by writing the rewrite URL in the URL address bar, but when go to the page by click on the link, the profile page URL doesn't change to rewrite URL. Am I missing something here?
this is my .htaccess codes
Options +FollowSymLinks
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^profile/?$ profile.php [NC,L] # Handle requests for "profile"
Thanks for any suggestions.
You need to change the URL of profile..
Profile
mod_rewrite will not change URLs in your code. You have to do it.
If you can't or don't want to, you can use RewriteRule with R option to map from old to new URL.
It doesn't change because your rule only internally rewrites profile to profile.php, you need a different rule to do it the other way, and externally so the browser gets redirected:
RewriteCond %{THE_REQUEST} \ /profile\.php
RewriteRule ^ /profile [L,R]

.htaccess redirect doesn't hide url

my .htaccess in the root folder includes the following lines :
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ http://example.com/?city=$1 [NC]
when I open the address http://example.com/bla.htm, my browser doesn't hide the GET values specified in the .htaccess, it redirects me to ?city=bla. eventhough I'm not using the [R] switch. This has always worked for me before (as I remember, haven't dealt with htaccess in a while). What's wrong here ?
When you redirect to an entire URL, it doesn't do URL rewriting (you can't exactly rewrite URLs on someone else's website).
Assuming both URLs are on the same server, you need to do something like
RewriteRule ^(.*)\.htm$ index.php?city=$1 [NC]
Also, I'd recommend getting into the habit of using the [L] switch whenever you can - it helps avoid bugs when you have a lot of URLs to rewrite.