我正在尝试为2个参数编写自定义URL
http://localhost/htaccess/site-list-pune-pune/xcxc
htaccess is my application fordername
但是我收到此错误“找不到对象!”
可能是我在最后一条规则中失踪了请帮助我
这是我的代码:
#Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*?)(?:\+|%20|\s)+(.+?)\sHTTP [NC]
RewriteRule ^ /%1-%2 [L,NE,R=302]
# To externally redirect /dir/foo.php?name=123 to /dir/foo
RewriteCond %{THE_REQUEST} ^GET\s(.*)/single-page\.php\?name=([^&\s]+)&dd=([^&\s]+) [NC]
RewriteRule ^ %1/%2/%3? [R,L]
# /htaccess/Movie.php?name=movie-name => /htaccess/movie-name
RewriteCond %{THE_REQUEST} ^GET\s([^.]+)\.php\?name=([^&\s]+)&dd=([^&\s]+) [NC]
RewriteRule ^ %1/%2/%2? [R,L]
# To internally forward /dir/foo/12 to /dir/foo.php?name=12
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/([^/]+)/?$ $1.php?name=$2&dd=([^&\s]+) [L,QSA]
# handle /htaccess/movie-name internally
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ single-page.php?name=$1&dd=([^&\s]+) [L,QSA]
内部网址:http://localhost/htaccess/single-page.php?name=pune-site-list-pune&dd=xcxc
答案 0 :(得分:1)
按此规则替换您的最后一条规则:
# handle /htaccess/movie-name internally
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ single-page.php?name=$1&dd=$2 [L,QSA]
([^&\s]+)
不能替代使用此正则表达式来捕获RewriteCond
中的值。