强制HTAccess在末尾加一个斜杠并解析php GET值
我有这样的安排强制HTAccess在末尾加一个斜杠并解析php GET值,php,.htaccess,root,url-redirection,Php,.htaccess,Root,Url Redirection,我有这样的安排 localhost/editor/index.php // This is the php file which require get variables localhost/editor/.htaccess // htaccess file which will pass values to index.php localhost/editor/variable1/variable2/ HTAccess文件:代码 RewriteEngine on RewriteC
localhost/editor/index.php // This is the php file which require get variables
localhost/editor/.htaccess // htaccess file which will pass values to index.php
localhost/editor/variable1/variable2/
HTAccess文件:代码
RewriteEngine on
RewriteCond %{REQUEST_URI} (.*)/(.*)/
RewriteRule (.*)/(.*)/ index.php?u=$1&e=$2
我想这样做的网址
localhost/editor/index.php // This is the php file which require get variables
localhost/editor/.htaccess // htaccess file which will pass values to index.php
localhost/editor/variable1/variable2/
在此之后,如果有人将错过一个斜杠结束,他将得到对象未找到的错误
我尝试了不同的方法,但无法解决此问题。您可以使用此代码
RewriteEngine On
RewriteBase /editor/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?u=$1&e=$2 [L]
这样,您就可以访问
localhost/editor/variable1/variable2
或
但我建议您选择一个,并禁止另一个(以避免重复内容)很高兴它起作用,不客气。如果有帮助的话,别忘了接受我的回答