使用htaccess将html页面扩展重定向到带有参数的php扩展不起作用
这就是我试图实现的目标。 我想重定向这样的东西使用htaccess将html页面扩展重定向到带有参数的php扩展不起作用,php,apache,.htaccess,mod-rewrite,redirect,Php,Apache,.htaccess,Mod Rewrite,Redirect,这就是我试图实现的目标。 我想重定向这样的东西 http://www.example.com/news/news-seo-title-with-unicode-maybe.html 到 这是我在htaccess文件中写的内容 Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)\
http://www.example.com/news/news-seo-title-with-unicode-maybe.html
到
这是我在htaccess文件中写的内容
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)\.html$ $1.php?seo_url=$2 [L]
我被重定向到news.php,但是$\u GET变量中没有任何内容。我的htaccess代码有错误吗?您可以使用:
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^.]+)\.html$ $1.php?seo_url=$2 [L,NC,QSA]
选项MultiViews
由Apache的内容协商模块使用,该模块在mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。所以/file
可以在URL中,但它将提供/file.php
。需要关闭它才能传入GET参数
Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^.]+)\.html$ $1.php?seo_url=$2 [L,NC,QSA]