Amuk Saxena
Amuk Saxena

Reputation: 1571

htaccess: Remove second part of url

Currently i have 100+ URLs on my site in this format:

http://www.example.in/view_retailer/homepage

I want to remove /view_retailer/ from all URLs, so they should look something like this

http://www.example.in/homepage

In other words I would to always remove /view_retailer/ from the url. I'm sure it's really straight forward, but I'm not very experienced with .htaccess

I have tried:

RewriteEngine on 
RewriteRule ^view_retailer/(.*)$ $1

This is my current htaccess file

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    <FilesMatch "\.inc.php">
      order deny,allow
      deny from all
    </FilesMatch>

     Options -MultiViews
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME}\.php -f
        RewriteRule ^(.*)$ $1.php            
        RewriteRule ^view_retailer/(.*)$ /$1 [L,R=301]  

Any help will be appreciated.

Thanks.

Upvotes: 0

Views: 344

Answers (1)

Ben Rhys-Lewis
Ben Rhys-Lewis

Reputation: 3246

RewriteEngine On
RewriteRule ^view_retailer/(.*)$ /$1 [L,R=301]

Adding the R will change the url to appear like the new version in your address bar

Upvotes: 1

Related Questions