Tag Archives: redirect

Redirect Without changing URL Apache

Questions: 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 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… Read More »

apache2 – https redirection to http for a given page

Questions: I have a specific problem about the redirection of HTTPS to HTTP for several pages. I have Apache2 in front of Zope. Here’s the configuration of my VirtualHost on port 80 : <VirtualHost *:80> ServerAdmin root@website.com ServerName website.com ServerAlias www.website.com <IfModule mod_rewrite.c> RewriteEngine On # www to non www RewriteCond %{HTTP_HOST} ^www.(.*) [NC] RewriteRule… Read More »

issue in redirecting 2 domains in one server

Questions: I have 2 domains and both are set on one server and when you open each of them , the same website from the same server opens . now i want to redirect one of them to another . for example I have www.first.com and www.second.com both on one server , and I want… Read More »

How to prevent one file from .htaccess redirect?

Questions: I am creating php front controller. this is my .htaccess file. <IfModule mod_rewrite.c> RewriteEngine on RewriteRule (.*) controller.php [L] </IfModule> This code redirect all url to the controller.php. I need to avoid redirect index.php to the controller.php. All other urls should redirect to the controller.php. Answers: You can use the following syntax to make… Read More »

Check cookie and redirect with Apache

Questions: I’d love to get some feedback on this. I’m not sure if it’s the right approach. The details I’m running Apache 2 with PHP 5.3/MySQL 4 and Drupal 6 is the platform. I’m developing a site which contains restaurant reviews in a couple of selected cities. When the users arrives at the site it… Read More »

.htaccess ErrorDocument Redirect

Questions: I am very new to Apache and .htaccess, and I had a simple question regarding how to handle 403 and 404 errors with Apache’s ErrorDocument command. Let’s look at this code from an early CMS I wrote: ErrorDocument 404 /admin/includes/access_deny.php?error=404 This will silently redirect the user to http://www.mysite.com/admin/includes/access_deny.php?error=404 when they get a 404 error.… Read More »

htaccess redirect hostname to FQDN

Questions: I have a machine that is local and if you type in http://host it goes to the website on it. I want to use an htaccess to redirect to http://host.domain.com. In the end it is the same I just want to use the proper url for documentation purposes. I tried this but didn’t work… Read More »

Redirect everything except images

Questions: I cant understand why but: RewriteCond %{HTTP_HOST} market\.mysite\.com$ [NC] RewriteCond %{HTTP_HOST} !^market\.mysite\.com$ [NC] RewriteCond %{REQUEST_URI} \.(png|jpe?g|bmp|gif|swf|css|js)$ [NC] RewriteRule ^(.*) http://market.mysite.com/$1 [L,R] RewriteCond %{REQUEST_URI} !^/index\.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L] Works as expected. Redirecting images to an other domain. But this one: RewriteCond %{HTTP_HOST} market\.mysite\.com$ [NC] RewriteCond %{HTTP_HOST} !^market\.mysite\.com$ [NC]… Read More »

htaccess redirect URL using partial value of string parameter

Questions: I have a bunch of products listed at https://www.example.com/all/products/foldername/1234567890-ProductDescriptionA-456.html https://www.example.com/all/products/foldername/7654321-SomeOtherDesc-B123.html https://www.example.com/all/products/foldername/93939393-anotherthing-F93939393.html and I want these to be redirected to https://www.example.com/products.php?p=1234567890 https://www.example.com/products.php?p=7654321 https://www.example.com/products.php?p=93939393 respectively. Is there an htaccess rule to do string operations on a matched parameter? For example, if I had to convert my URL using Python, it would look like this: def make_new_url(old_url):… Read More »