How to stop htaccess redirect replacing URL - .htaccess

I have the following in my .htaccess file which works fine, except that when I hit:
http://bunkerbuster.com/profiles/1
The URL in the address bar is replaced with the new URL. I don't want this to happen, I want the URL to still show bunkerbuster.com
Thanks for your help.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^profiles/([0-9]+)$ http://projectzebra-bunkerbuster.herokuapp.com/profiles/$1 [R,L]
RewriteRule ^profiles/([0-9]+)/$ http://projectzebra-bunkerbuster.herokuapp.com/profiles/$1 [R,L]

What you seem to be trying is make Apache act as a proxy.
This can't be done using htaccess but can be done using mod_proxy :
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxypass

Related

Rewrite url via htaccess on apache server

I have a url which is
www.domain.com/index.php?route=ticketsystem/generatetickets
I want people who type in the url www.domain.com/contact to be redirected to the page index.php?route=ticketsystem/generatetickets however have the url bar still show /contact is that possible via htaccess and if so how? I tried the below
RewriteEngine On
RewriteBase /
RewriteRule contact /index.php?route=ticketsystem/generatetickets [L,QSA]
For your shown attempts, please try following .htaccess rules file. Make sure your index.php and .htaccess files are present in same directory/folder. Also better to use & rather than using / for query string.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^contact/?$ index.php?route=ticketsystem&generatetickets [QSA,NC,L]

URL REWRITING : Redirect a link to the new

I am a beginner in the REWRITING URL and in fact I replaced this link http://www.downisynet.rf.gd/article.php?id=14 with http://www.downisynet.rf.gd/tutoriel/14
Yet both links are still accessible.
So I want to know how to redirect the old URL to the new one?
Here is my .htaccess code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel-([0-9]+) article.php?tutoriel=$1 [L]
Thank you for helping me!
You can simply 301 redirect one page to another using .htaccess. Add the following to your .htaccess file:
RewriteEngine on
Redirect 301 /article.php?id=14 http://www.downisynet.rf.gd/tutoriel/14
Modified rule for /tutoriel/any-digit to /article.php?tutoriel=any-digit
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^tutoriel\/([0-9]+)$ /article.php?tutoriel=$1 [L]

mod_rewrite not working

I'm new to working with .htaccess and I'm having trouble using mod_rewrite for apache.
So basically I have a URL. www.website.com/test/index.php
and I'd like it to be shorter www.website.com/t/index.php
So in my .htaccess file I have these three lines:
RewriteEngine On
RewriteBase /
RewriteRule ^test/(.*) t/$1 [R=301,L]
This works perfectly for directing me to www.website.com/t/index.php but the index.php page wont load and will only display a 404 error. Any help would be greatly apprectiated.
You need to do the shortening of your URL first:
RewriteEngine On
RewriteRule ^test/(.*) t/$1 [R=301,L]
...and then make sure, the new (and nonexisting) URL will get processed:
RewriteRule ^t/(.*) test/$1 [L]
The first rewrite is "external", so it is displayed in client browser address bar, but the second is "internal", so apache only displays results from the new URL in place of the old one w/o any change in clients address bar.

Circular htaccess rewrite rules

This seems like exactly what you would want to do with the htaccess rewrite rules. But I can't seem to get it to work properly.
I have this page on my site: http://wireie.gocactus.com/network_extensions.php
I want to rename it to: http://wireie.gocactus.com/transparent-ethernet-solutions
So this is the line I put in my htaccess file:
RewriteRule ^transparent-ethernet-solutions network_extensions\.php [NC]
Alrighty. Now if I go to /transparent-ethernet-solutions, it works great.
The problem is that, /network_extensions.php also still works great. So I'll want to rewrite that url with this line:
RewriteRule ^network_extensions\.php*$ /transparent-ethernet-solutions [R,NC]
Now it gives me an error message about too many redirects. If I add the second line without the first line, it changes the URL on the PHP link but gives me a 'page not found' error on the pretty link redirection.
My mind is blown. Can I have the URL rewritten without forwarding and have the new URL work without redirecting from the old one? I'm not sure if there's just some parameter I'm missing in the first line, or some combination of rules necessary.
This is the code that will be needed in your .htaccess:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^transparent-ethernet-solutions/?$ network_extensions.php [NC,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+network_extensions\.php\s [NC]
RewriteRule ^ transparent-ethernet-solutions [R=301,L]

htaccess URL Rewrite for products doesn't redirect me

There is plenty of information out there but nothing I've read on the interwebz has given me an answer as to why my htaccess is not working.
I cannot determine why my rule isn't rewriting the URL as I thought it would. I have the following url:
domain.com/Book/bookpage/index.php?bookID=123&bookName=foo_bar
I would like to change it so that when someone hits that URL, it shows like:
domain.com/Book/123/foo_bar
I started off trying to get it to work using just the Book ID and haven't even gotten that to work.
This is what I have thus far:
RewriteRule ^Book/([0-9]+)$ /Book/bookpage/index.php?bookID=$2
However, after placing that htaccess in the root of the site and going to the URL:
domain.com/Book/bookpage/index.php?bookID=123
The URL in the address bar remains the same.
try this:
RewriteEngine On
RewriteBase /
# this rewrite domain.com/Book/123 or domain.com/Book/123/
RewriteRule ^Book/([0-9]+)/?$ /Book/bookpage/index.php?bookID=$2 [L,NC,QSA]
# this rewrite domain.com/Book/123/title or domain.com/Book/123/title/
RewriteRule ^Book/([0-9]+)/([a-z0-9\-_]+)/?$ /Book/bookpage/index.php?bookID=$1&bookName=$2 [L,NC,QSA]
Try adding [L,R=301] at the end of the line:
RewriteRule ^Book/([0-9]+)$ /Book/bookpage/index.php?bookID=$2 [L,R=301]

Resources