Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect Without changing URL Apache

I want to redirect one URL to another without changing the Browser URL

www.example.com/abc/(.*).xml should redirect to www.example.com/abc/xyz/index.htm?file=$1

But the Browser should display www.example.com/abc/(.*).xml

like image 366
Constantine Avatar asked Feb 03 '15 12:02

Constantine


People also ask

How to redirect domain without changing url in Apache web server?

Sometimes you may need to redirect domain pages without changing URL in Apache web server. Here’s how to redirect and keep original URL using .htaccess. You can use it to redirect domain or page without changing URL. Here are the steps to redirect and keep original URL using htaccess.

How to redirect WWW to non-www in Apache htaccess file?

Here are the steps to redirect www to non-www in Apache htaccess file. Please ensure that you have enabled mod_rewrite in your Apache web server configuration. Only then your htaccess configuration will be applied by Apache server.

How to execute simple and one-page redirects with Apache?

The Redirect directive lets you execute simple and one-page redirects with Apache. It connects an old URL with a new one by asking the client to fetch the resource again at the new location. The Redirect directive requires at minimum two arguments: the old URL and the new URL. To accomplish the redirect, add the following lines to your server ...

What is the redirect directive in Apache?

The Redirect directive lets you execute simple and one-page redirects with Apache. It connects an old URL with a new one by asking the client to fetch the resource again at the new location.


1 Answers

You can use a RewriteRule:

RewriteEngine On
RewriteRule /abc/(.*)\.xml$ /abc/xyz/index.htm?file=$1 [L]

Make sure you have mod_rewrite enabled and put this either in your VirtualHost config, or in a .htaccess file in your DocumentRoot

like image 136
arco444 Avatar answered Oct 23 '22 04:10

arco444