【问题标题】:mod_rewrite.c is not found in apache 2.4.4在 apache 2.4.4 中找不到 mod_rewrite.c
【发布时间】:2013-11-07 13:57:11
【问题描述】:

我在 apache 2.4.4 中找不到 mod_rewrite.c;但我启用了 mod_rewrite。是否需要运行以下 .htaccess 文件,因为我收到错误 500 内部服务器错误。

<IfModule mod_rewrite.c>
# Enable mod_rewrite
RewriteEngine On
# Specify the folder in which the application resides.
# Use / if the application is in the root.
RewriteBase /phpcs5
# Rewrite to correct domain to avoid canonicalization problems
# RewriteCond %{HTTP_HOST} !^www\.example\.com
# RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Rewrite URLs ending in /index.php or /index.html to /
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
# Rewrite category pages
RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$ index.php?Depart
mentId=$1&CategoryId=$2&Page=$3 [L]
RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/?$ index.php?DepartmentId=$1&Cate
goryId=$2 [L]
# Rewrite department pages
RewriteRule ^.*-d([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&Pag
e=$2 [L]
RewriteRule ^.*-d([0-9]+)/?$ index.php?DepartmentId=$1 [L]
# Rewrite subpages of the home page
RewriteRule ^page-([0-9]+)/?$ index.php?Page=$1 [L]
# Rewrite product details pages
RewriteRule ^.*-p([0-9]+)/?$ index.php?ProductId=$1 [L]
</IfModule>

【问题讨论】:

    标签: php apache .htaccess mod-rewrite xampp


    【解决方案1】:

    嗯,一方面,你有大量的杂散换行符,这将 100% 导致 500 个服务器错误:

    <IfModule mod_rewrite.c>
    # Enable mod_rewrite
    RewriteEngine On
    # Specify the folder in which the application resides.
    # Use / if the application is in the root.
    RewriteBase /phpcs5
    # Rewrite to correct domain to avoid canonicalization problems
    # RewriteCond %{HTTP_HOST} !^www\.example\.com
    # RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
    # Rewrite URLs ending in /index.php or /index.html to /
    RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html?)\ HTTP
    RewriteRule ^(.*)index\.(php|html?)$ $1 [R=301,L]
    # Rewrite category pages
    RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2&Page=$3 [L]
    RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2 [L]
    # Rewrite department pages
    RewriteRule ^.*-d([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&Page=$2 [L]
    RewriteRule ^.*-d([0-9]+)/?$ index.php?DepartmentId=$1 [L]
    # Rewrite subpages of the home page
    RewriteRule ^page-([0-9]+)/?$ index.php?Page=$1 [L]
    # Rewrite product details pages
    RewriteRule ^.*-p([0-9]+)/?$ index.php?ProductId=$1 [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-20
      • 2013-12-12
      相关资源
      最近更新 更多