RewriteRule, url wrongly displayed

I am new to mod_rewrite and I have this problem:

I have a working redirect with mod_rewrite, my .htaccess:

RewriteEngine on RewriteRule ^microsite/([^/\.]+)/$ micrositecontroller.php?name=$1 [L]

micrositecontroller.php only echoes a text

On the browser when I enter my URL:


I am redirected to where wanted but when I enter:


It still redirects to where wanted but the URL becomes like this:


Now what I want is that trailing "/?name=test" not to show up.

I tried different combinations of the regex but to no avail and I have no idea if it is normal of not. Any idea?

-------------Problems Reply------------

You have a slash in your regex, so your regex handles slash... just remove it:

RewriteEngine on
RewriteRule ^microsite/([^/\.]+)$ micrositecontroller.php?name=$1 [L]

What you want is:

RewriteEngine on
RewriteRule ^microsite/([^/\.]+)/?$ micrositecontroller.php?name=$1 [L]
# Note the "?"-------------------^

To accommodate both ending with a slash and no slash. The problem with leaving the slash on (or off) is apache forces a browser redirect, thus making the ?name=test show up in the browser's location bar.

This is because mod_dir and the DirectorySlash on directive is interferring. The DirectorySlash directive tells apache to redirect the browser when it accesses what looks to be a directory (in your case localhost/project/microsite/test to the smae URI except with a trailing slash.

Category:apache Views:0 Time:2011-11-15

Related post

  • Downloads images from URL and display it in a GridView 2011-06-13

    I have a URL where some images are exists. I want to retrieve all the images from that URL and display these images in the GridView. Now when I click any of thumb preview like in grid view then it should enlarge or load to full screen. putting the sn

  • Structuring a URL to display all results for scraping data 2011-07-24

    I am a GIS student working on a project focused on mapping unstructured data, in which I wrote a php script to scrape the following page that displays search results for US GIS job postings, to export to xml, geocode and map.

  • I'm looking for a Sharepoint Webpart that can query a list for an RSS feed URL, then display it 2011-11-23

    Basically what I have a List that will be maintained by the user that has a field that contains a link to an RSS feed. I tried using the OOTB RSS and it's great, but you have to specify the feed URL and I need that to be based on user selection. For

  • After URL redirection, url not displaying new address when clicking on links 2011-04-13

    I've got this website,, it's a Joomla CMS with the SOBI2 business index installed. I've set it up so that their can be different entries based on their building location. SEF is turned on for both Joomla and SOBI2. I've s

  • Silverlight User Experience URL Image Displays? 2009-09-08

    I have a database that contains a table for storing URL Images (since storing the images as byte arrays could potentially slow the DB down massively). There are two fields in the image table, one that stores a URL to a low resolution image and one th

  • How to pass a parameter to a javascript through a url and display it on a page? 2010-03-08

    For instance, I have a url like this : How do I pass a value " Use_Id = abc " to it and use javascript to display on that page ? --------------Solutions------------- Shouldn't be too difficult to write your own without the

  • Mod Rewrite MS Hosting Hide Long Annoying URL By displaying the short URL? 2010-03-16

    Scenario : I have a PHP Forum and a Asp.Net site hosted on Linux and MS Hosting respectively (obvious right?!). My domain is currently configured with PHP host whereas my ASP.Net site is using the default 1and1 generated URL (s0987465.onlineh

  • django / python get image from url and display on site 2010-03-22

    Given a url to an image is there a way in Django/Python to pull this image in and then display it on my site (resized if possible) Thanks --------------Solutions------------- If you just want to hotlink it print out the html snippet(<img src="http

  • htaccess url regex display "&" if backreference is matched 2011-04-08

    I'm using IsapiRewriter on IIS6, but I think this question is more general than that. I'm also pretty sure there's no way to do it, but decided I should ask folks who know more regex than I do before giving up completely. I'm matching url tails like

  • Validate URL and display as a link in PHP 2011-05-10

    When I display the text from database, I want to detect whether that text is URL and if that's with URL format, i want to hyperlink those text automatically. For example, if my text is like this "Hey, check this out, i found a great website and i wou

  • How can I write url /:lang/display-cv-:cvid using zend_config? 2011-05-19

    I got a zend_config file called routes.ini. Currently my url looks like this /:LanguageCode/display-cv/:CVID as defined by this route: routes.display-cv.route = /:LanguageCode/display-cv/:CVID routes.display-cv.defaults.controller = users-profile rou

  • How to grab the first image from page url and display it along BOOKMARK description? 2011-09-13

    I am developing a social bookmarking website in ASP.NET and in it I am displaying bookmarks which users add. I want to put the fist image of web page along with bookmarks to display to user. but I don't know how I get that . Update (14.09.11): Here's

  • How to display image from an URL and display it on tap of a UIButton? 2011-11-14

    I want to know how to display image from URL (which is in xml file) on tap of button. --------------Solutions------------- UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(20, 20, 200, 44); // positi

  • Strip URL only display domain 2011-11-21

    I have a url,, and I would like to display only exampledomain onto my page. strip out 'http://members' and '.com' For example's index page has something like <img src="members/image

  • How to remove parameters in URL and display it in address bar without causing redirect in Javascript? 2011-12-14

    I have found numerous answers on how to extract the URL without the parameters. How do you rewrite the URL in the address bar without causing the page to reload with the new URL? shortURL = top.location.href.substring(0, top.location.href.indexOf('?'

  • android - download the image from url not displaying correctly 2011-12-29

    In my app, when you click on the button then I am downloading the images from the url's. It displaying the images some time correctly but some time it display empty. *problem is some times bitmap object(i.e, "result" in code ) return null.*please can

  • HTML anchors and CSS: select only some URLs to display in @media print 2012-01-03

    In my print style sheet, I want URLs displayed after most links. So, I have: a:after { content:" (" attr(href) ") ";} For the links where I don't want URLs, I have: a.ignore:after { display: none; } and then I use <a class="ignore" href="http://ex

  • Adding Image URL after displaying the Image in Wordpress 2012-03-03

    I am trying to display the URL of an Image after every image in the main content on Wordpress. To do this I am building a plugin. If add the following code within my plugin I can display 2 of the same Image. as the code to display the image is stored

  • Does facebook graph api needs image url for displaying image? 2012-03-12

    I have a webpage and a F-Share button. On clicking this button, an image uploaded by the user is posted on facebook. I tried to initially use javascript to set the 'picture' property with image data from fileupload and it didn't work. So, my guess is

Copyright (C), All Rights Reserved.

processed in 0.134 (s). 11 q(s)