MOD Rewrite Mask for Image URL - mod-rewrite

Okay so I am launching a cloned e-commerce site. I want to create a rewrite rule for the image folder for the second site to fetch images from the first site.
RewriteRule ^alice.gif$ www.rhinomart.com/images/h_home.gif
When I go to alice.gif directly through the browser it simply redirects me to the rhinomart.com URL and image. How do I prevent the redirect from occurring? When I go to http://www.acnbiz.net/alice.gif it should fetch alice.gif directly from Rhinomart.com/images and not redirect. is it possible???

If you want to rewrite to an external site but not redirect the browser then you will need to proxy the request by enabling mod_proxy and using the [P] flag.

Related

How do I set a redirect for my root index.html in jekyll?

I have jekyll-redirect-from plugin, but it only really works for pages that aren't my root homepage.
For example, if a user types in www.mywebsite.com/index.html I want it to redirect and display the URL as www.mywebsite.com
Everything I can find about this is focused on blog posts and other pages than the index. Has anyone had this issue?
You don't need a redirect, because www.mywebsite.com/index.html and www.mywebsite.com are the same page. (The browser just shows the index file by default if you go to www.mywebsite.com.)
You need the browser to rewrite the URL, while remaining on the same page. You need to do this on the webserver.
.htaccess
If your site is on an Apache server and you have access to the server, you can use an .htaccess file to rewrite the URL from www.mywebsite.com/index.html to www.mywebsite.com.
There are online .htaccess generators like this one that help get the syntax right.
There are similar methods for rewriting URLs on nginx webservers.
GitHub Pages
If you're on a service like GitHub Pages, you can't use .htaccess. A free workaround is to use Netlify to deploy your site, because you can set up redirects on Netlify. Create a free account on Netlify and add a new site from GitHub there.
In the root of your repo, create a netlify.toml file containing this:
# Redirect /index.html to /
[[redirects]]
from = "/index.html"
to = "/"
Netlify will now handle that redirect.

URL rewrites not working and keep changing the URL extension

I cannot get the URL rewrite in Magento to work correctly at all. I'm trying to redirect a category to a CMS page and at first try it works fine. After I refresh, it starts to change the URL extensions to something completely different than what's shown for the category URL. I've tried clearing the cache and reindexing the URL rewrite but that seems to change it again!
And if I do try to change the URL rewrite to this new, random, made up one that's being automatically inputted - it changes it again! I'm so confused here..
Fixing weird URL Rewrites
Sometimes when you make changes to your products, or enable a certain extension, Magento might start to rewrite all your URLs to include a suffix "-1" or some other number. Within the URL Rewrites, Magento differentiates between System URLs and Custom URLs. If the System URLs are broken like this, you should not fix this by adding new Custom URLs.
Instead, open up phpMyAdmin, create a backup of your Magento database, and flush the Magento table core_url_rewrite (so that it becomes totally empty). Immediately afterwards, refresh the Catalog Url Rewrites under Index Management. This will regenerate all System URLs.
You can also try to redirect through the .htaccess.
Redirect 301 /site-URL-to-redirect www.site.com/url-destination
There are two ways to redirect your category page to cms.
Using Magento native URL rewrite managment.
In Magento 1.x go to
admin -> catalog -> url rewrite managment -> add new url
select custom in Create URL Rewrite: drop down and then give your categoy url as request and cms page as target.
Using .htaccess file. Add this line of code into the file .htaccess:
Redirect category-url cms-page-url

Hide real URL with ISAPI Rewrite?

Is it possible to hide real URL with HeliconTech's ISAPI Rewrite module? To be more specific, consider the following scenario:
User requests an URL "example.com/something".
"In the background", server redirects the request to another URL "anotherexample.com".
Contents from "anotherexample.com" are returned to the user (user still sees "example.com/something" in his/her browser address bar after response has been received).
So, the user must not be aware of the fact that contents came from different URL. If this isn't possible with ISAPI Rewrite, do there exist another ways to implement the functionality (in IIS 6 + SharePoint 2007 environment)?
This is achieved using proxy functionality in ISAPI_Rewrite 3. Here are the rules to put in .htaccess in the root of example.com site:
RewriteBase /
RewriteRule ^(.*)$ http://www.anotherexample.com/$1 [P]

URL Rewrite to remove my controller's name from the url displayed

I have this site
http://cjbuilders.info/welcome/home
and all the links start with
http://cjbuilders.info/welcome
How can I use mod_rewrite to just remove
/welcome/
from the url? This should be an easy one, but i struggle with mod_rewrite.
Do you know about CodeIgniter's URI Routing? Add this into your routes.php config file and it should work just fine:
$route['home'] = 'welcome/home';
This should work, IIRC:
RewriteRule ^/welcome/(.*)$ /$1 [R]
However, guessing a bit about what's going on here, if the reason for this prefix is something like a Java app server deploying an app at a context called "welcome", then the better solution is not to rewrite the URLs but to fix the backend app server to have a null context, i.e. serve at / rather than at /welcome/.
This is because the app server will probably want to generate links to other views of its app, and will reinsert the "welcome": this becomes a pain, and means that all links on your pages will get HTTP redirects when visited (e.g. by search engines). There is no way that the proxying apache server can parse the HTML and tell when that "welcome" should be removed, so best to fix the server that's writing the links in the first place.

mod_rewrite one url to another url without changing source url

Is it possible to do a mod_rewrite from one url to another without changing what appears in the address bar?
Example:
Source URL is http://domain1.com/news
Target URL is http://domain2.com/news
I want to render pages from http://domain2.com/news/ but have http://domain1.com/news appear in the address bar.
Is this possible?
I've got this directive, but the URL in the address bar changes (which I don't want to happen):
RewriteRule ^(.*)$ http://domain2.com/news/ [L,NC]
As far as I know, it cannot be done with just a mod_rewrite rule that rewrites one domain to another. The http:// prefix causes an external redirect, which is why you see it in your browser. The server at domain1 sends the redirect back to the browser and the browser has to re-request from domain2. To avoid this, the server at domain1 has to be able to retrieve data from domain2. If you control both servers, I've heard you can use mod_proxy to accomplish this, but I don't know the details.
For rules that do not go from one domain to another, the normal behavior of mod_rewrite will not cause the browser to change the URL unless you use the [R] flag.

Resources