Forum Moderators: phranque

Message Too Old, No Replies

Generating SE friendly URL .htaccess mod rewrite

Generating SE friendly URL .htaccess mod rewrite

         

nandla

6:51 am on Nov 18, 2011 (gmt 0)

10+ Year Member



I've a URL which get file name through get method and display it on the page.

tvchaska.info/i/

this is the page and when u click any image it will go to; say

tvchaska.info/i/output.php?i=http://brothertattoo.co.uk/wp-content/uploads/2011/09/Sexy-Girl-Tattoo.jpg 

I want my this URL to be rewritten as

tvchaska.info/i/Sexy-Girl-Tattoo.html


I tried following rule but it is not working

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /output.php?i=$1 [L]

Can any one plz help me to attain this plz?

phranque

10:13 am on Nov 18, 2011 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



everything after the "?" in the url is the query string.
the pattern in the RewriteRule is applied to the current requested url path.
the group you are trying to capture exists in the query string, so you will have to use a RewriteCond directive to capture from the QUERY_STRING server variable the part of the requested url you wish to use for the redirection url.

mod_rewrite:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html [httpd.apache.org]

lucy24

10:23 am on Nov 18, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you plz start by reminding yourself that u r not texting your friends on a cell phone?

Luckily you are asking the Question of the Hour, which means there are approximately eight trillion earlier posts in this forum addressing the same question. Pick any three recent pages at random and read all the threads. At least a quarter of them will have a question similar to yours.

Start by getting a firm grip on the difference between Redirect and Rewrite. Here you are first redirecting to the "friendly" URL-- using {THE_REQUEST} so you don't go into an infinite loop-- and then rewriting back to the "real" URL.

Then you need an equally firm grip on the direction of your rewrite. A lot of people seem to get it backward.

And finally you can explain exactly what you mean by "is not working". See, you know what it means but we don't. Nothing happening at all? The wrong thing happening? The server crashes?