Hi there,
I just wonder why this RULE does not work:
[
'blog/' => 'blog/index',
'blog/<id:\d+>/' => 'blog/view',
];
As you can see, I have added slash (’/’) at the end of rule.
Thanks.
Hi there,
I just wonder why this RULE does not work:
[
'blog/' => 'blog/index',
'blog/<id:\d+>/' => 'blog/view',
];
As you can see, I have added slash (’/’) at the end of rule.
Thanks.
This will mess with your get request making them not work unless you have a way to handal the trailing /.
In your htacess you could do something like
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
But that will add it to al of your urls
Thank you for the answer. I’ll try it later. It looks better.
Yes, I’d like to have it in my all URLs and I want to make 301 redirection if user types with non-slash (example.net/blog/some-title) to slash (example.net/blog/some-title/). It’s because of avoiding duplicate content.
It does not work.
.htaccess in my root folder:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^admin$ backend/web/$1 [L]
RewriteRule ^(.*)/$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]
.htaccess in my frontend/web folder:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
In Yii 1 this was so easy…
I just found…
http://www.yiiframework.com/doc-2.0/yii-web-urlmanager.html#$suffix-detail
Anyway, just need to make 301 redirect from non-slash to slash.