简体   繁体   中英

add trailing slash and remove .htaccess

How can I do something like this that: website.com/store/ redirect to website.com/store website.com/outbound/store/5 redirect to website.com/outbound/store/5/

what I want is to have for urls without prefix to remove trailing slash and for those with prefix to add trailing slash

my .htaccess:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)/$ /$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^pa/?$ /admin/index.php [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ stores.php?store=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^outbound/([^/]*)/([^/]*)$ /outbound.php?type=$1&id=$2 [L]
Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# force tailing slash for all urls starting with /outbound/
RewriteRule ^outbound/.*[^/]$ /$0/ [R=301,L]

#remove tailing slash for all except urls starting with /outbound/
RewriteCond $1 !^outbound/
RewriteRule ^(.+)/$ /$1 [R=301,L]

RewriteRule ^pa/?$ /admin/index.php [L,QSA] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^outbound/([^/]*)/([^/]*)/$ /outbound.php?type=$1&id=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ stores.php?store=$1 [L]

I also cleaned it up a bit.

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