下面是我的htaccess的样子:
Here's what my htaccess looks like:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.site.com$ [NC]
RewriteRule .? http://site.com%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_URI} /page1/([^?].*)$ [NC]
RewriteRule /page1/(.*)$ /page1/?$1 [L] # change /page1/stuff to /page1/?stuff
# End rewriting for page1
RewriteCond %{REQUEST_URI} /page2/([^?].*)$ [NC]
RewriteRule /page2/(.*)$ /page2/?$1
# End rewriting for page2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^/]+/)*index.php HTTP/
RewriteRule ^(([^/]+/)*)index.php$ http://%{HTTP_HOST}/$1 [R=301,NS,L]
Options -Indexes
我也想是有它,如果用户进入 site.com/page1/stuff
或 site.com/page1/东东/多
这将增加一个斜线在地址栏中并将其更改为 site.com/page1/stuff /
和 site.com/page1/stuff/more /
,但没有我想的作品。有没有办法做到这一点,而不会导致重定向循环?
What I also want is to have it that if a user goes to site.com/page1/stuff
or site.com/page1/stuff/more
it will add a trailing slash in the address bar and change it to site.com/page1/stuff/
and site.com/page1/stuff/more/
but nothing I tried works. Is there any way to do this without causing a redirect loop?
我希望所有我的网址有一个结尾的斜线,我看到已经这样做。目录
I want all my urls to have a trailing slash and I see directories already doing that.
编辑:为了澄清,我想最后的斜线是对用户可见的,而不是
To clarify, I want the trailing slash to be visible to the user but not the ?
推荐答案
感谢该链接的@LazyOne,反正这个作品:
Thank for that link @LazyOne, anyway this works:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*[^/])$ /$1/ [L,R=301]
相关推荐
最新文章