【问题标题】:.htaccess not working on localhost.htaccess 在本地主机上不起作用
【发布时间】:2014-12-31 10:50:51
【问题描述】:

我在我唯一的.htaccess 文件中完成的代码:

Options FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule blue-world.pl/([a-z]+)(?:/([a-z]+))? index.php?nav=$1#$2

我需要将blue-world.pl/name/name2 重定向到blue-world.pl?nav=name#name2。如何做到这一点使其工作BOTH:本地主机和服务器。

在 MAMP 中我尝试输入:localhost/scregal.blue-world.pl/title 我看到了:

The requested URL /scregal.blue-world.pl/title was not found on this server.

以下是我在 localhost 中的文件层次结构:

scregal.blue-world.pl
    - .htaccess
    - index.php -> var_dump($_GET)

httpd.conf 中有以下几行:

LoadModule rewrite_module modules/mod_rewrite.so

AllowOverride All

【问题讨论】:

    标签: .htaccess localhost mamp


    【解决方案1】:

    你可以使用这条规则:

    Options FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)(?:/([^/]+))?/?$ index.php?nav=$1#$2 [L,QSA,NC]
    

    【讨论】:

    • 那么我的可能有什么问题?我刚刚复制并粘贴了您的代码。
    • 我的错误,名称中没有'git'关键字。
    猜你喜欢
    • 2016-12-30
    • 2012-08-17
    • 2012-05-03
    • 2021-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多