.htaccess重定向不会发生

时间:2015-11-26 08:20:18

标签: javascript php .htaccess http-status-code-404

我有一个动态的JavaScript链接:

https://example.com/~scale/playground/[my dynamic value]

我在JavaScript中生成此值。点击此链接后,它会在我的数据库中查找[my dynamic value]并重定向到上述值的网址。

我的.htaccess看起来像这样:

RewriteBase /playground/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?id=$1 [L]

但单击链接时显示404错误。为什么我的.htaccess不工作?

1 个答案:

答案 0 :(得分:0)

看看这个。你可以得到一个我希望的想法

# RewriteBase equivalent - Production
RewriteCond %{HTTP_HOST} !^localhost$
RewriteRule . - [E=REWRITEBASE:/]

# RewriteBase equivalent - Development
RewriteCond %{HTTP_HOST} ^xx\.xx\.xx\.xx$
RewriteRule . - [E=REWRITEBASE:/~countryr/]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/-]+)/?$ %{ENV:REWRITEBASE}page.php?pid=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ %{ENV:REWRITEBASE}blog-detail.php?url=$1 [QSA,L]