This is my .htaccess
file:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule !\.(css|js|ico|zip|rar|png|jpg|gif|pdf)$ index.php [L]
AddType application/x-httpd-php .php .phtml
and I need to know how to add trailing slash to end of URL when I have this code:
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
for add www
in .htaccess
For example URL without code for this:
www.example.com/introduction
and with this code:
www.example.com/introduction/
Have it this way:
AddType application/x-httpd-php .php .phtml
RewriteEngine On
RewriteBase /
# add www
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# add a trailing slash to non-files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|ico|zip|rar|png|jpe?g|gif|pdf)$ index.php [L,NC]
RULE FOR IIS USERS : ADDING / TO All URL. Worked for all seo
<rule name="Add trailing slash" stopProcessing="true">
<match url="^(.*)([^/])$" />
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="(.*?)\.[a-zA-Z]{1,4}$" negate="true" />
</conditions>
<action type="Redirect" url="{R:0}/" redirectType="Permanent" />
</rule>
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.