douzhuang6321 2011-10-31 09:35
浏览 39

.htaccess不会重写网址

I have this problem: The administrator of the server says that he had rewrite_module enabled for the apache server but when I upload some test files to the server to test this functionality it does not work.

I have it enabled at localhost and it works perfectly fine there.

.htaccess content:

Options +FollowSymlinks
RewriteEngine on 
RewriteRule ^games/(.*)$ games.php?id=$1 [L]

games.php content:

<?php 
$var = $_GET['id'];
echo $var;
?>

URLS:

localhost url:http://localhost/testing/games/123123
production url:http://mysite.com/test2/games/123123 

test2 is the folder that contains the files (.htaccess and games.php) What happens in production is that when i type this i get the page games.php but the id does not get echoed and query string is empty instead of getting the id 123123 which I provided.For localhost everything works fine and I get the id echoed. Maybe the administrator is wrong or what? Thank you in advance.

  • 写回答

1条回答 默认 最新

  • dongmubei7950 2011-10-31 09:46
    关注

    You are in subdirectories and you're telling the engine to rewrite when the request begins exactly with 'games'. You can try to remove the caret ^, or replace it with a slash / ... or add this after RewriteEngine on :

    RewriteBase /testing/
    

    in production:

    RewriteBase /test2/
    

    Or try:

    RewriteEngine On
    RewriteBase /test2/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^games/(.*)$ games.php?id=$1 [QSA,L]
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度