[英]Newbie issue with url rewriting
I have few questions and I need your advice. 我有几个问题,需要您的建议。 So I'm building mini CMS system where users submit content and I construct an url from their content's headline and id eg "74/my-name-is-john-stewart" and insert it to DB besides original context.
因此,我正在构建一个微型CMS系统,用户在该系统中提交内容,并从其内容的标题和ID(例如“ 74 / my-name-is-john-stewart”)构建一个网址,并将其插入到原始上下文之外的DB中。 When I retrieve data with GET method deal?url=74/my-name-is-john-stewart I wonder how to convert that link to deal/74/my-name-is-john-stewart format like in Stackoverflow.
当我使用GET方法Deal?url = 74 / my-name-is-john-stewart检索数据时,我想知道如何将该链接转换为Deal / 74 / my-name-is-john-stewart格式,就像在Stackoverflow中一样。 And I have doubts if it's a proper way, cause when user deletes id number part, different content is loaded, but url's title part stays the same.
而且我怀疑这是否是正确的方法,导致当用户删除id号部分时,加载了不同的内容,但是url的标题部分保持不变。 I'm afraid , maybe it might cause some SEO problems in the future?
恐怕将来可能会引起一些SEO问题?
You can use these rules in /deal/.htaccess
: 您可以在
/deal/.htaccess
使用以下规则:
RewriteEngine On
RewriteBase /deal/
RewriteCond %{THE_REQUEST} \s/+(deal)\?url=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L]
# internal forward from pretty URL to actual one
RewriteRule ^([^/.]+)/?$ ?q=$2 [L,QSA,NC]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.