views:

147

answers:

3

hi let me explain in brief.

I have a url - "http://Domain.com/FolderName/Default.aspx?EditID=6" with query string.

I need to show that url like below

"http://Domain.com/FolderName/Name"

...that means I want to remove "Default.aspx?EditID=6" part from url and want to replace it with some name ...

Can you help me.

Thanks in advanced...... thanks a lot....

A: 

Check out this article here.

At a glance, this should work (but I haven't actually tested it):

# Turn on the rewriting engine
RewriteEngine On
# Change requests that match "FolderName/Name/" to "FolderName/Default.aspx?EditID=6"
RewriteRule ^FolderName/Name/?$ FolderName/Default.aspx?EditID=6 [NC]

Steve

Steve Harrison
Hi thanks for your help...but remember that you have to write base url in your code to work with rewrite rule....
A: 

Assuming you have mod_rewrite enabled:

RewriteEngine On

#prevent an infinite rewrite loop
RewriteRule ^Community/Default\.aspx - [L]

#rewrite the names
RewriteRule ^Community/([^/]+) /Community/Default.aspx?N=$1 [L,NC,QSA]

In your /Community/Default.aspx, you need to resolve EditName to EditID - e.g. look it up in some table you define.

Edit: Unfortunately, the rewrite module doesn't know which name maps to which ID (unless you make a separate rule for each ID, which doesn't scale at all). So the rewrite module passes the name as N to your Default.aspx and it is the script's responsibility to find out which ID is meant.

Piskvor
A: 

This is what I currently use to redirect as well as allow certain domains through with certain files for hotlinking:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?google.com/.*$ [NC]
RewriteRule \.(gif|jpg|png|zip|js|css)$ - [F]
Gautam