.htaccess 使用get变量重写url

.htaccess 使用get变量重写url,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我想将写为product/5。我不是说用户键入doamin.com/product/5以获得结果,我要寻找的是-当用户单击链接时,浏览器地址栏将显示url为domain.com/product/5 有可能吗?如果您有任何帮助,我们将不胜感激。请提前感谢。只要写: <a href="/product/5">LINK</a> 使用,您将获得一个$\u get[''u route'],其值将为/product/5。其余部分由php代码来解析该字符串。…将href位置更改为“/

我想将
写为product/5。我不是说用户键入doamin.com/product/5以获得结果,我要寻找的是-当用户单击链接时,浏览器地址栏将显示url为domain.com/product/5

有可能吗?如果您有任何帮助,我们将不胜感激。请提前感谢。

只要写:

<a href="/product/5">LINK</a>

使用,您将获得一个$\u get[''u route'],其值将为/product/5。其余部分由php代码来解析该字符串。

…将href位置更改为“/product/5”?你在问什么?非常感谢,工作正常。因为我是这个领域的新手,只是为了了解-这样做是安全的方法吗?我想用这种方法处理$_get[]的方向正确吗?我听说这对SEO有好处。如果你能推荐一些好文章给潜在的赢家。再次感谢。这种方法和“?id=5”一样安全。这取决于你,如何“安全”处理你得到的变量。这肯定会提高你的搜索引擎优化,也会让分享你的链接变得更容易。想象一下在手机上:“嘿,伙计,看看这个:domain.com/product=128e947dje747”或者只是“domain.com/redshirt”:)但不要做得太过分。一个像“/公司的红衬衫和蓝脖子”这样的域名不会增加可读性和搜索引擎优化。最后一个提示是:在你的URL中使用“-”而不是“\ux”,因为谷歌更喜欢这样。如果您想要更多信息,请搜索“mod_rewrite”、“clean URL”、“Slug”…)
# turn mod_rewrite engine on 
RewriteEngine On

# rewrite all physical existing file or folder
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d

# allow things that are certainly necessary
RewriteCond %{REQUEST_URI} "/css/" [OR]
RewriteCond %{REQUEST_URI} "/images/" [OR]
RewriteCond %{REQUEST_URI} "/images/" [OR]
RewriteCond %{REQUEST_URI} "/javascript/"

# rewrite rules
RewriteRule .* - [L]
RewriteRule (.*) index.php?_route=$1 [QSA]