Mod_rewrite无法在localhost Apache / 2.4.17上运行

时间:2016-11-11 16:06:13

标签: php apache .htaccess

我一直试图在Apache / 2.4.17中重写clen url我使用下面的代码并且在线工作正常但在localhost中不起作用

this.af.database.list('operations', {
        query: {
          orderByChild: 'products/productID',
          equalTo: myProdID
        }
      }).remove();

上面的代码显示了这个

  

找不到对象!

     

在此服务器上找不到请求的URL。如果您输入了URL   请手动检查您的拼写,然后重试。

     

如果您认为这是服务器错误,请与网站管理员联系。   错误404 localhost Apache / 2.4.17(Win32)OpenSSL / 1.0.2d PHP / 5.6.23

现在我也只在localhost中试过这个,但它工作但不正确

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /my_website_dir/
#remove extention
RewriteRule ^([^/\.]+)/?$ $1.php  [L,QSA]

RewriteCond %{THE_REQUEST} /userprofile\.php\?u=([^\s&]+) [NC]
RewriteRule ^ /userprofile/u/%1? [R=301,L]
RewriteRule ^userprofile/u/([^/]+)/?$ /userprofile.php?u=$1 [L]

这是我得到的 本地主机/ my_website_dir / USERPROFILE / U /彼得 当我想获得你的参数值时,我得到Options +FollowSymLinks -MultiViews RewriteEngine on RewriteBase /my_website_dir/ #remove extention RewriteRule ^([^/\.]+)/?$ $1.php [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ userprofile.php?u=$1 [L] ,但我只需要在userprofile/u/peter

中返回 peter

1 个答案:

答案 0 :(得分:1)

使用以下内容更改最后一行

RewriteRule ^userprofile/u/([^/]+)/?$ userprofile.php?u=$1 [L]