Mobile app version of vmapp.org
Login or Join
Hamm4606531

: Set Alias path using .htaccess I have a path like this http://host.ip/nl/producten-en-diensten/abonnementen-met-gsm which will retrieve the correct content and I also want to receive the same content

@Hamm4606531

Posted in: #Apache #Htaccess #Magento #Php #UrlRewriting

I have a path like this
host.ip/nl/producten-en-diensten/abonnementen-met-gsm

which will retrieve the correct content and I also want to receive the same content when I access the below URL also
host.ip/nl/business/producten-en-diensten/abonnementen-met-gsm

Note:


host.ip/nl/ - Static
producten-en-diensten/abonnementen-met-gsm - Dynamic, it will change
/business keyword will append next to nl


I have referred to the rule given in this post: How can I create a shorter alias URL to a longer URL using an .htaccess file?

but no success
@Magento URL rewrite management will do exactly this, but I am trying to achieve this using .htaccess.

I have tried like this but it is redirecting

RewriteRule (^|.*?/)nl/business/(.*)$ /nl/ [R=302,L,NC]


Here is my rewrite tag in .htaccess

<IfModule mod_rewrite.c>

############################################
## Enable rewrites

Options +FollowSymLinks
RewriteEngine on

## Business Rewrite
RewriteRule (^|.*?/)nl/business/(.*)$ /nl/ [NC]

############################################
## You can put here your magento root folder
## path relative to web root

#RewriteBase /magento/

############################################
## Workaround for HTTP authorization
## in CGI environment

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

############################################
## TRACE and TRACK HTTP methods disabled to prevent XSS attacks

RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]

############################################
## Never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

############################################
## Rewrite everything else to index.php

RewriteRule .* index.php [L]

</IfModule>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Hamm4606531

1 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

Just remove the R=302, from your rule. R means "redirect" and 302 means "temporary type":

RewriteRule (^|.*?/)nl/business/(.*)$ /nl/ [L,NC]


For further info about your rule:


L means "last" (don't apply further rewrite rules)
NC means "no case" (case insensitive so /NL/BUSINESS will also match -- this may not be what you want)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme