Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I've recently been trying to come up with a way of masking the visible URL in the browser (so not 301 redirecting) and still show the same content as the original URL.

Here is the scenario...

Current URL's are like:-

domain.com/parent-category/sub-category/filter/brand

(parent-category and sub-category will always be the same word).

I wish to continue showing the content from those URL's but convert the URL's to show like:-

domain.com/brand-keyword

(keyword will always be the same word).

I'd really appreciate it if any experts on .htaccess could advise if this is possible please. It is a Magento store by the way.

The following has previously been suggested to me:-

RewriteRule ^parent-category/([^/]+)/filter/([^/]+)/?$ /$2-$1 [L,NC]

But this didn't have the desired affect... (Didn't change the visible URL in browser yet adding R, 301 redirects it though).

Specific Example

Current URL domain.com/showering/showers/filter/alliance

Required URL domain.com/alliance-showers

share|improve this question
    
Can anyone assist with this at all? –  zigojacko Mar 25 at 11:42
    
Your question is quite hard to understand. While I get the general problem you are having, you mix brand and keyword a lot and don't explain very well the end result you want to achieve.. –  edvinas.me Mar 25 at 20:27
add comment

1 Answer 1

You define a rule backwards, so this is not working. The syntax is as following:

Syntax of RewriteRule

This would work, but will most likely break your magento (as all urls with a dash "-" in it will be rewritten):

RewriteRule ^/(.*)-(.*)$ /parent-category/sub-category/$2/$1 [L,NC]

So I would suggest putting it under some kind of static keyword, like "shop", so when you access domain.com/shop/brand-filter it will rewrite to /parent-category/sub-category/filter/brand:

RewriteRule ^/shop/(.*)-(.*)$ /parent-category/sub-category/$2/$1 [L,NC]

More information: http://httpd.apache.org/docs/current/rewrite/intro.html

The regular expressions (.*) mean one or more characters, where:

  • . (dot) means at least one character;
  • * (star) means zero or more characters;
share|improve this answer
    
Thanks for your answer. I've added a specific example to the question if that is easier to understand. I've tried your suggestion but the URL doesn't change. The URL just remains as domain.com/showering/showers/filter/alliance Thanks –  zigojacko Mar 26 at 7:41
add comment

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.