Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have to write a redirect rule for the below condition.

www.domain.com/custom.aspx?ATTR=VALUE to www.domain.com/custom?ATTR=VALUE

How can this be achieved using the .htaccess

I have the below set of codes using on the current .htaccess file. Please also suggest where to include your code.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^api/rest api.php?type=rest [QSA,L]
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
    RewriteRule .* - [L,R=405]
    RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L]
</IfModule>
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

This could be done using mod_rewrite, eg something like this:

RewriteEngine On
RewriteRule ^(.*)\.aspx(.*)$ /$1$2 [R=301,L]
share|improve this answer
    
Yes! I am using the mod_rewrite. But using the above rule lead me to the 404 page. –  PHP Bugs Aug 30 '12 at 6:50
    
Do you mean that your browser gets properly redirected to www.domain.com/custom?ATTR=VALUE, but that URL returns a 404? If so, then why would you want to redirect there? –  brain99 Aug 30 '12 at 7:29
    
No redirection is happening here. My page stays at www.domain.com/custom.aspx?ATTR=VALUE –  PHP Bugs Aug 30 '12 at 7:43
    
I may have been a bit too quick, I just updated my answer. Could you try that variation instead? –  brain99 Aug 30 '12 at 8:28
    
The result is same. The page is not redirecting. I have edited my question with the current .htaccess file. Please check these as well. –  PHP Bugs Aug 30 '12 at 8:46
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.