我使用的是从stackoverflow.com/q/8583856 htaccess的 -
I'm using htaccess from stackoverflow.com/q/8583856 -
RewriteEngine on
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://www.mysite.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+).php([#?][^ ]*)? HTTP/
RewriteRule ^(.+).php$ http://www.mysite.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ http://www.mysite.com/profile.php?u=$1 [NC]
Everything works great unless I type www.mysite.com into address bar -
returns mysite.com/profile?u=index.html.var
which errors "Unknown column index.html.var in where clause"
任何人都知道如何得到这个去mysite.com/index~~V呢?
Anyone know how to get this to go to mysite.com/index instead?
尝试添加一个条件,以检查是否路径为空(即根)
try adding a condition to check if the path is empty (i.e. root)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond $0 ^$
RewriteRule .* - [L]
上一篇:除去codeigniter子域的index.phpcodeigniter、index、php
下一篇:htaccess的mod_rewrite的"请求超过了10内部重定向的限制,由于可能的配置错误。 "重定向、错误、超过了、mod_rewrite