2010-04-12 79 views
1

我试图创建微小的网址是这样的:努力创造微小的网址,让重定向循环

site.com/abc123

去:

网站.com/index.php?token = abc123

但是我不断收到重定向循环?在我试试,或者它试图重定向到的index.php令牌=的index.php ..

当前的.htaccess是:

Options +FollowSymLinks 
Options -MultiViews 
RewriteEngine On 
RewriteRule ^([^/]*)$ /index.php?token=$1 [L] 
+0

试图'^ [A-ZA-Z0-9] $'为你的正则表达式;看看是否有帮助? – meagar 2010-04-12 03:03:19

+0

试过但仍然给出了重定向循环。 – Gary 2010-04-12 03:07:07

回答

1

这里就是我做了(我重定向字母数字代码像http://myurl.com/b32ad):

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{SCRIPT_FILENAME} !-f 
RewriteCond %{SCRIPT_FILENAME} !-d 
RewriteRule (.*) /index.php?token=$1 [L] 
0

这很奇怪,因为你有[L]选项附加到该规则。有没有外部由别的东西引起的重定向?

无论如何,您可以将规则限制为不存在文件(也许是目录)的请求。

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]*)$ /index.php?token=$1 [L] 

看到http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond