简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM