.htaccess Url重写和修剪Url
我需要你宝贵的帮助 我有一个网址:.htaccess Url重写和修剪Url,.htaccess,url-rewriting,.htaccess,Url Rewriting,我需要你宝贵的帮助 我有一个网址: http://domain.com/v/12345 My ht access设置为将12345传递给php脚本,如下所示: htaccess: RewriteRule ^v/([a-zA-Z0-9_-]+)$ /script.php?v=$1 [L] 脚本php: http://domain.com/script.php?code=12345 而且工作得很好但是。。还有一个,但是,我会写我的url,这样: http://domain.com/1234
http://domain.com/v/12345
My ht access设置为将12345传递给php脚本,如下所示:
htaccess:
RewriteRule ^v/([a-zA-Z0-9_-]+)$ /script.php?v=$1 [L]
脚本php:
http://domain.com/script.php?code=12345
而且工作得很好但是。。还有一个,但是,我会写我的url,这样:
http://domain.com/12345/my-dog-is-very-fat
你能帮我改变一下我的工作权限吗?因为如果我使用/我的狗很胖或只是/我得到一个404错误
我试图更好地解释:
例如,我会在url中与seo关键字共享链接
mydomain.com/alphanumericCode/thi-is-my-dog-article
从myscript.php?V中获取alphanumericCode的位置=
这是我的htaccess:
RewriteEngine On
RewriteRule ^view/([a-zA-Z0-9_-]+)$ /view.php?v=$1
RewriteRule ^folder/([a-zA-Z0-9_-]+)$ /filefolderlist.php?f=$1
RewriteRule ^home$ /index.php [L]
RewriteRule ^report$ /report.php [L]
RewriteRule ^play/([a-zA-Z0-9_-]+)$ /play.php?v=$1 [L]
###Added by anubhava
RewriteRule ^v/([\w-]+)/?$ /script.php?v=$1 [L,QSA]
RewriteRule ^([0-9a-z]+)/.+$ /script.php?v=$1 [L,QSA,NC]
##end
RewriteRule ^privacy-policy$ /privacy.php [L]
ErrorDocument 404 404.php
您可以为新URI方案设置新规则:
RewriteEngine On
RewriteRule ^v/([\w-]+)/?$ /script.php?v=$1 [L,QSA]
RewriteRule ^([0-9a-z]+)/.+$ /script.php?v=$1 [L,QSA,NC]
不起作用,我的朋友,你的代码只对最后一个有效,但是如果在我再次得到404之后放一些东西(感谢您的帮助!没有收到您的评论。您在浏览器中输入的导致404的URL是什么?是否有比显示的这两个更多的规则?是的,我有这些规则:RewriteEngine On RewriteRule ^v/([a-zA-Z0-9_-]+)$/view.php?v=$1 RewriteRule^文件夹/([a-zA-Z0-9_-]+)$/filefolderlist.php?f=$1您没有告诉我哪个URL导致了404?我不能在这里显示我的网站,我用这个URL得到了404,例如:mydomain.com/codeForGet/ErrorWords如果我写错了,我的脚本将进入404