[英]Rewrite Dynamic URLs to Friendly URLs
我研究了许多有关如何重写动态URL的不同问题,无论出于何种原因,我都无法获得它们用于我的代码。 我知道我需要编辑.htaccess文件。
当前网址:example.com/search/profileview.php?storeid = 1&store = aqua-addicts
理想的网址:example.com/search/profileview/aqua-addicts.html
如果不可能,那么可以从URL中删除?,&和=的所有内容。 这是我目前在无法正常工作的.htaccess中尝试的操作。
编辑:澄清无法正常工作,我有一页根据搜索条件生成结果。 该页面上的链接是:等同于example.com/search/profileview.php?storeid=1&store=aqua-addicts
我希望能够单击链接并将URL更改为友好版本。
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+profileview\.php\?storeid=([^&]*)&.*?store=([^&\s]*) [NC]
RewriteRule ^ profileview-storeid-%1-store-%2.html? [R=302,L]
RewriteRule ^profileview-storeid-([^-]+)-store-([^.]+)\.html$ profileview.php?storeid=$1&store=$2 [L,QSA,NE]
任何帮助表示赞赏。 我知道对于某些人来说,这可能是一个简单的更改,但是我已经尝试解决了大约一天半的时间。
尝试这个。 它不会自动应用重定向,但可以删除不需要的重定向? 从URL。
RewriteEngine On
RewriteRule ^search/profileview/(.*).html?$ search/profileview.php?storeid=$1&store=$2 [QSA,NC,L]
然后,您可以调整永久链接,例如search / profileview / aqua-addicts.html
尝试这个
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^search/profileview/([^/]+).html search/profileview.php?storeid=1&store=$1 [L]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.