0

我最近买了一个 php 网站,它使用 .htaccess 中的 RewriteRule 来重定向 url,例如 domain.com/login 被重定向到 domain.com/login.php 或 /register 到 /register.php 等等。这些是我的 .htaccess 文件的内容:

options -multiviews
<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteBase /
RewriteRule ^users$ users.php
RewriteRule ^login$ login.php
RewriteRule ^logout$ logout.php
RewriteRule ^log_out$ log_out.php
RewriteRule ^forgot$ forgot.php
RewriteRule ^manage_gigs$ manage_gigs.php
RewriteRule ^manage_orders$ manage_orders.php
RewriteRule ^new$ new.php
RewriteRule ^suggestions$ index.php
RewriteRule ^search$ search.php
RewriteRule ^edit$ edit.php
RewriteRule ^edit_extra$ edit_extra.php
RewriteRule ^bookmark$ bookmark.php
RewriteRule ^bookmarks$ bookmarks.php
RewriteRule ^settings$ settings.php
RewriteRule ^balance$ balance.php
RewriteRule ^order$ order.php
RewriteRule ^orders$ orders.php
RewriteRule ^inbox$ inbox.php
RewriteRule ^conversations/([^/.]*)?$ conversations.php?u=$1&%{QUERY_STRING}
RewriteRule ^upload$ upload.php
RewriteRule ^check_new$ check_new.php
RewriteRule ^spam$ spam.php
RewriteRule ^thank_you$ thank_you.php
RewriteRule ^track$ track.php
RewriteRule ^send_track$ send_track.php
RewriteRule ^confirmemail$ confirmemail.php
RewriteRule ^rss$ rss.php
RewriteRule ^terms_of_service$ terms_of_service.php
RewriteRule ^privacy_policy$ privacy_policy.php
RewriteRule ^about$ about.php
RewriteRule ^contact$ contact.php
RewriteRule ^advertising$ advertising.php
RewriteRule ^signup$ signup.php
RewriteRule ^forgotpassword$ forgotpassword.php
RewriteRule ^feature$ feature.php
RewriteRule ^feature_success$ feature_success.php
RewriteRule ^purchases$ purchases.php
RewriteRule ^suggested$ suggested.php
RewriteRule ^mysuggestions$ mysuggestions.php
RewriteRule ^myreferrals$ myreferrals.php
RewriteRule ^levels$ levels.php
RewriteRule ^categories/([^/.]+)?$ cat.php?cid=$1&%{QUERY_STRING}
RewriteRule ^user/([^/.]+)?$ user.php?uname=$1&%{QUERY_STRING}
RewriteRule ^tags/([^/.]+)/([^/.]+)?$ tags.php?cid=$1&tag=$2&%{QUERY_STRING}
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]*)?$ view.php?title=$1&id=$2&%{QUERY_STRING}
</IfModule>
<IfModule mod_security.c> 
   # Turn off mod_security filtering. 
   SecFilterEngine Off 

   # The below probably isn't needed, 
   # but better safe than sorry. 
   SecFilterScanPOST Off 
</IfModule>

但是单击任何链接会导致 404 错误(找不到页面),因为没有重定向 url。我正在使用cpanel。我是否必须激活某些功能才能使其工作?这里可能有什么问题?谢谢。

4

2 回答 2

1

您似乎没有启用重写规则。

  1. 打开httpd.conf;

  2. 找到mod_rewrite.so提到的那条线;

  3. 去掉#前面的标签( );

  4. 重新启动您的网络服务器;

于 2013-02-06T07:30:27.807 回答
0

更改 RewriteBase / 方式 RewriteBase / Your folder /

于 2015-09-22T18:50:41.430 回答