我在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>
答案 0 :(得分:0)
嗯,首先,你有大量的流浪新行,这将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>