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.

For SEO purposes, I need to modify my .htaccess file. Here's what I need to do:

current URL: www.abc.com/ index.php?page=product_types&cat=88

to

new URL: http://www.abc.com/amazing

So if someone types in http://www.abc.com/amazing, they must be served content from the current URL, but the new URL must stay in the address bar. I tried this and it works:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)amazing(.*)$ index.php?page=product_types&cat=88

But what if someone typed in the current URL and I want it to redirect to the new URL, how does that work? I feel like this is going to end up being a loop if I use rewrite again.

share|improve this question
    
Do you want to redirect the user if they visit the "old" URL? –  Shane Madden Sep 13 '12 at 1:49
    
That's the right - the old url should not be accessible, i.e. the new shortened version must come up instead. –  Ray Sep 13 '12 at 1:50
1  
@Ray then you have two problems: 1. you need an external redirect from the "old" url to the "new" url, and 2. you need an internal redirect from the new url to the PHP script. You'll also need to do this without making a loop. Your 2.5nd problem is that your current rule matches /amazing/regexes/rock/my/world/hard/ Is there a reason you've got all that stuff after amazing? –  DerfK Sep 13 '12 at 2:13
    
@DerfK: I've modified the question to make it clearer, could you let me know how you would approach this? –  Ray Sep 13 '12 at 4:44
    
@Ray How are you planning on connecting the friendly URL to the ugly URL - is there any logic to it, or just a big list? Do you need to use .htaccess, or do you have access to the Apache config on this system? –  Shane Madden Sep 13 '12 at 5:51
show 1 more comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.