[英]how to hide id from the url and make it clean url my directory of .htaccess file is /home/evidhya/public_html/tutorials/.htaccess
I have following url i would like to hide id and make it clean url我有以下网址,我想隐藏 id 并使其成为干净的网址
https://www.evidhya.com/tutorials/tutorials.php?qid=569/AJAX/Introduction
clean url should be like below url https://www.evidhya.com/tutorials/AJAX/Introduction
干净的网址应该像下面的网址
https://www.evidhya.com/tutorials/AJAX/Introduction
I'm able to achieve using below htaccess code.我可以使用下面的 htaccess 代码来实现。
https://www.evidhya.com/tutorials/569/AJAX/Introduction
but i don't want 569
id in url https://www.evidhya.com/tutorials/569/AJAX/Introduction
但我不想在 url 中使用569
id
RewriteEngine On
#RewriteBase /KSTA-Webinar/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
#RewriteRule ^(\d+)/?$ tutorials.php?qid=$1/$2/$1/$3 [L,QSA]
RewriteRule ^([\w.-]+)/?$ get_data.php?qid=$1 [L,QSA]
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^title=([^/]+)/([^/]+)/([^/]+)/(.+)$
RewriteRule ^tutorials\.php$ /%1/%2/%4? [R=301]
RewriteRule ^tutorials/([\w+%]{2,50})$ /tutorials.php?qid=$1 [QSA,L]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ tutorials.php?qid=$1&user=$2&date=$3
RewriteRule ^([^/]+)/([^/]+)/(.+)$ tutorials.php?qid=$1/$2/$1/$3 [L]
Well, it seems the id is needed to determine the resulting url.好吧,似乎需要 id 来确定结果 url。 I would do this:
我会这样做:
RewriteEngine on
RewriteRule (\d+)/(\w+)/(\w+) tutorials.php?qid=$1/$2/$3 [L]
and place this rule in tutorials/.htaccess
.并将此规则放在
tutorials/.htaccess
。
And when someone goes to https://www.evidhya.com/tutorials/569/AJAX/Introduction it should load https://www.evidhya.com/tutorials/tutorials.php?qid=569/AJAX/Introduction当有人访问https://www.evidhya.com/tutorials/569/AJAX/Introduction 时,它应该加载https://www.evidhya.com/tutorials/tutorials.php?qid=569/AJAX/Introduction
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.