【问题标题】:my website go in 404 page when i put this code in htaccess?当我将此代码放入 htaccess 时,我的网站进入 404 页面?
【发布时间】:2016-03-31 11:27:33
【问题描述】:

我需要这个

www.mydomain.com/apple
www.mydomain.com/banana
www.mydomain.com/mango

www.mydomain.com/search.php?q=apple
www.mydomain.com/search.php?q=banana
www.mydomain.com/search.php?q=mango

这行不通
我的网站进入 404 页面
我的 .htaccess

选项 +FollowSymLinks
RewriteEngine on

重写规则 ^(.*) search.php?q=$1

【问题讨论】:

  • 如果你想要这样的 url 参数,你可能正在 PHP 中寻找 $_GET。

标签: php .htaccess url url-rewriting


【解决方案1】:
Options +FollowSymLinks
RewriteEngine on
#If the request is not for an existent directory
RewriteCond %{REQUEST_FILENAME} !-d
#And file
RewriteCond %{REQUEST_FILENAME} !-f
#Then rewrite the request 
RewriteRule ^(.*)$ /search.php?q=$1

【讨论】:

  • 虽然这段代码可以回答这个问题,但最好解释一下它的作用并添加一些引用。
猜你喜欢
  • 1970-01-01
  • 2016-10-16
  • 2015-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-11
  • 1970-01-01
  • 2018-05-13
相关资源
最近更新 更多