Mobile app version of vmapp.org
Login or Join
Harper822

: Masking / mapping URL's with .htaccess 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

@Harper822

Posted in: #Htaccess #ModRewrite #UrlRewriting

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/([^/]+)/?$ /- [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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Harper822

1 Comments

Sorted by latest first Latest Oldest Best

 

@Chiappetta492

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



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// [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// [L,NC]


More information: 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;

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme