在htaccess中重写url

时间:2016-01-26 18:01:57

标签: .htaccess

我想访问movies.php?m=Bengali Audio,但是采用这种格式movies/Bengali Audio我会编写这些.htaccess代码,但显示文件未找到,movies.php?m=Bengali Audio工作正常

RewriteEngine On
# Rewrite for movies.php?m=Bengali Audio
RewriteRule ^movies/([0-9a-zA-Z_-]+'')$ movies.php?m=$1 [NC,L]

1 个答案:

答案 0 :(得分:1)

您可以使用此正则表达式模式匹配电影名称中的空格:

Options -MultiViews
RewriteEngine On

# Rewrite for movies.php?m=Bengali Audio
RewriteRule ^movies/([^/]+)/?$ movies.php?m=$1 [NC,L,QSA]